[Twisted-web] Nevow application as a plugin
tarjei
tarjei at nu.no
Thu Aug 23 07:07:04 EDT 2007
Hi, as part of making my application ready for prime time, I'm looking
for solutions / suggestions to a few problems.
My goal is to be able to launch the application using twistd <appname>
--some-param and not have to know the path to the app.tap file and be
able to mix normal twistd commandline options and extra application
specific options.
Does anyone have an example of a Nevow application running as a plugin? [1]
Is the document referenced above using the new plugin system or the old
one? (twisted.plugins vs twisted.python.plugin)
I have found some nuts and bolts, but I am not too sure on how they fit
together.
As I've understood it, if I got a package myapp that contains the
modules for the application, then there should be a file inside this
directory called plugins.tml that defines the twisted plugin.
This file contains a method:
register('myapp', 'myapp.tap',
description='My webapp',
type='tap', tapname='myapp')
then I can run "twisted myapp" to run this class. I would expect there
to be an extra interface to do the actual creation of services. As I've
understood it, that is the role of the function makeService(config)
function that should be placed in myapp/tap.py.
Is this correct or very wrong? What is the correct way to do this? What
is missing? I tried to find the interface for the register function, but
I didn't find it. Please give me some pointers or an example of how to
do this.
As you can see, I think I understand 20% of plugins - but am missing the
other 80.
I've tried subclassing the Options class to be able to add my own
configuration options. When I do this and try to start the application
using twistd -oy app.tap, it bombs out because the normal twistd
commandline options are not included. What am I doing wrong?
class VdOptions(usage.Options):
optParameters = [
['config', 'c', '/etc/app.ini'],
]
cli = VdOptions()
try:
cli.parseOptions() # When given no argument, parses sys.argv[1:]
except usage.UsageError, errortext:
print '%s: %s' % (sys.argv[0], errortext)
print '%s: Try --help for usage details.' % (sys.argv[0])
sys.exit(1)
Links:
1.http://twistedmatrix.com/projects/core/documentation/howto/tutorial/configuration.html
Thanks a lot for any input on this.
Kind regards,
Tarjei
More information about the Twisted-web
mailing list