When a client interacts with my program by requesting resources, I feel that these resources should be able to manipulate data stored in my program's memory. For example, my script files (.rpy) follow this pattern: # a.rpy import A as X if __debug__: reload(X) resource = X.MyResource() # A.py from twisted.web import resource class MyResource(resource.Resource): def render(self, request): # generate content # shove it in variable, say, my_content return my_content # my_server.py from twisted.application import internet from twisted.application import service from twisted.web import static from twisted.web import server from twisted.web import script from twisted.internet import reactor application = service.Application('web') sc = service.IServiceCollection(application) root = static.File("c:/wwwroot") root.ignoreExt(".rpy") root.processors = {'.rpy': script.ResourceScript} site = server.Site(root) i = internet.TCPServer(8080, site) i.setServiceParent(sc) reactor.listenTCP(8080, site) reactor.run() Okay, so I run my program from the command line as: $ python my_server.py Everything seems to work. Now suppose I have b.rpy, c.rpy, d.rpy, etc. (and corresponding modules: B.py, C.py, D.py, etc.). I want all of these resources to be able to share and manipulate the same data (from memory, not disk) between requests. Now that I think about it, the term "application" is vague. In my post, application should be taken to mean a set or collection of web pages (or resourses using twisted's vocabulary), but I guess it can also be taken mean the program, "my_server.py". I appreciate you taking an interest in this.
-----Original Message----- From: Michal Pasternak [mailto:michal@pasternak.w.lub.pl] Sent: Thursday, April 01, 2004 2:10 PM To: twisted-web@twistedmatrix.com Subject: Re: [Twisted-web] Application variables?
How does one share "application data" between requested
Rilee, Robert [Thu, Apr 01, 2004 at 11:46:17AM -0500]: scripts (or should I
say resources)?
And what "application data" is for you?
-- Michal Pasternak :: http://pasternak.w.lub.pl :: http://winsrc.sf.net
_______________________________________________ Twisted-web mailing list Twisted-web@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
participants (1)
-
Rilee, Robert