[Twisted-Python] "glue" problem
p.mayers at imperial.ac.uk
Sat Apr 19 13:19:44 EDT 2008
Dr Pythoniac wrote:
> Hi all
When posting a new topic, please don't use reply-to on a previous
different topic, it breaks threading.
> concerning twisted.web:
> How do I run once-per-application stuff ?
> Assume, I want to put sth into the static.Registry or I want to read
> in some application data from a file, so that every resource can use
> My main problem can be split in two:
> - where do it do it (using twistd) ? Please no complicated plugin (or
> alike) suggestions. I'm seeing red just hearing 'zope' ...
Assuming you are using a .tac file, you might do something like this in
from twisted.application import service, strports
application = service.Application('myapp')
services = service.IServiceCollection(application)
# do startup code here
site = mycode.site()
web = strports.service('tcp:80', site)
...then run the "tac" file with:
twistd -oy application.tac
...this is such a simple solution that I guess you are having more basic
> - how can resource scripts use it ?
What does this mean?
> Probably this is an idiots question but I have sth. like 8
> Browsertabs open with twisted "docu" and getting more and more
> confused by hunting pieces of information that are just splattered
> all over the site.
Have you read the finger tutorial from start to end, and understood it?
> Additional: Is there any docu about twistd ? How can I use all its
> miracles rather than just dumbly guess and try an err and try and err
> and ... ?
...describes the contents of a ".tac" file, the recommended way to use
twistd. If you could be more specific about *what* you don't understand,
what you've tried already, why it didn't work and with what error
messages, I can perhaps be more helpful.
More information about the Twisted-Python