Pylons creates new controllers and projects by adding command to paste. The commands are defined in setup.py and you can add new commands.
For example (this is taken from the Paste docs) lets assume you have a project called Foo that is in a package also called foo.
In setup.py add 'foo' to the 'paster_plugins' list
Then add a new command to entry_points.
ie
entry_points="""
[paste.paster_command]
mycommand = foo.commands.test_command:Test
"""
Create a directory called 'commands' under 'foo', add a __init.py__ file and create a file called test_command.py
In the file add
from paste.script import command
class TestCommand(command.Command):
max_args = 1
min_args = 1
usage = "NAME"
summary = "Say hello!"
group_name = "My Package Name"
parser = command.Command.standard_parser(verbose=True)
parser.add_option('--goodbye',
action='store_true',
dest='goodbye',
help="Say 'Goodbye' instead")
def command(self):
name = self.args[0]
if self.verbose:
print "Got name: %r" % name
if self.options.goodbye:
print "Goodbye", name
else:
print "Hello", name
After you run 'python setup.py develop' you can now run 'paste mycommand bob' and you should get 'Hello bob' output.
To see how Pylons adds to this to create new files etc. look in pylons/commands.py they have commands for creating new Controllers and RestControllers that you can copy.