Roelof Naudé wrote:
Hi
Is it possible to have a persistent method/class/process running in the ZOPE framework?
Sure.
For example an online trading site would have some connectors (CORBA or XLMRPC) to an external system to do the trades. The connectors can be a python class. This class will place an order and have to wait for a reply, but since a reply can take too much time, one would have an asynchronous call. The class/process still needs to stay resident so that it can act on the reply, e.g. write reply to database/send mail to users etc. Also it could monitor clients portfolios and send e-mail or some other notification when a specific share is above or below a certain threshold.
How this was coded would depend on whether it was truly asynchronous or not. For things like monitoring potfolios, you may wish to simply start a Python thread that makes the external connection and waits for inputs. This thread would make connections to the object database as needed to handle specific events. If you need the response to the external call to create a web response, then you will need to have web requests lock till you get a reply. This requires some tricky coding but may avoid the need for a dedicated thread. You may need a combination of these approaches. If you can test for external events via a select call, you should be able to recieve external events via the asyncore main loop used by ZServer. This would avoid the need for a dedicated thread and probably simplify event handling a bit. Jim -- Jim Fulton mailto:jim@digicool.com Python Powered! Technical Director (888) 344-4332 http://www.python.org Digital Creations http://www.digicool.com http://www.zope.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.