Play!Framework‎ > ‎

Play! - writing my first module

As I was using Play, I found out a missing module that a simple version for it can be pretty easy to create.

If you know rails, (and if you don't, you should), there is a rake task to install gems.
When you translate this to rails - a module that will install all other modules.

This will enable you to quickly install a new instance running these two commands

play modules:install
play run

Create a new Module


First lets run the command
play new-module  modules


Now since our module will be really simple (and will assume a lot of things), we will only use the "commands.py".
And even though it sounds "too simple", you would be amazed at how easy it is to
  • Learn Python
  • Get important functionalities from your module
For a good source samples, and example on good usage for this simple implementation, see commands.py of the "migrate" module. (play install migrate-1.2) - go to "play_home/modules/migrate-1.2"

The entire migrate module is written in the commands.py - and it allows you to version your DB. A very powerful feature.


Deploying you module


Once you have the python script written, you will want to copy it to play_home/modules/name-version and use it on a project.. however, it seems there's no such command.

Luckily, we are writing a modules module! so lets just add a "deploy" command that will do everything for us

Building your module


The command for building a module is

play build-module

Play will prompt you for the required play version to run this module, and the module version.



References


The best reference so far, is to simply run
play help


Comments