trying to use twisted in a Zope 2 instance
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3503 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
a4e055bb66
commit
d021473fbf
3 changed files with 53 additions and 0 deletions
4
twisted/z2/__init__.py
Normal file
4
twisted/z2/__init__.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
"""
|
||||||
|
$Id$
|
||||||
|
"""
|
||||||
|
|
11
twisted/z2/configure.zcml
Normal file
11
twisted/z2/configure.zcml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<!-- $Id$ -->
|
||||||
|
|
||||||
|
<configure
|
||||||
|
xmlns:zope="http://namespaces.zope.org/zope"
|
||||||
|
xmlns:browser="http://namespaces.zope.org/browser">
|
||||||
|
|
||||||
|
<zope:subscriber
|
||||||
|
for="zope.app.appsetup.interfaces.IDatabaseOpenedWithRootEvent"
|
||||||
|
handler="cybertools.twisted.z2.startup.startup" />
|
||||||
|
|
||||||
|
</configure>
|
38
twisted/z2/startup.py
Executable file
38
twisted/z2/startup.py
Executable file
|
@ -0,0 +1,38 @@
|
||||||
|
|
||||||
|
"""
|
||||||
|
Code to be called at Zope startup.
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
"""
|
||||||
|
|
||||||
|
from twisted.internet import reactor
|
||||||
|
from OFS.Application import AppInitializer
|
||||||
|
from zope.event import notify
|
||||||
|
from zope.app.appsetup.interfaces import DatabaseOpenedWithRoot
|
||||||
|
|
||||||
|
|
||||||
|
def startup(event):
|
||||||
|
print '*** Database opened: %s' % event.database
|
||||||
|
#twisted_target(event.database)
|
||||||
|
|
||||||
|
|
||||||
|
base_install_standards = AppInitializer.install_standards
|
||||||
|
|
||||||
|
def install_standards(self):
|
||||||
|
result = base_install_standards(self)
|
||||||
|
notify(DatabaseOpenedWithRoot(self.getApp()._p_jar.db()))
|
||||||
|
return result
|
||||||
|
|
||||||
|
#AppInitializer.install_standards = install_standards
|
||||||
|
#print '*** AppInitializer monkey patch installed'
|
||||||
|
|
||||||
|
|
||||||
|
def twisted_target(db):
|
||||||
|
reactor.callLater(5, show_application, db)
|
||||||
|
|
||||||
|
|
||||||
|
def show_application(db):
|
||||||
|
c = db.open()
|
||||||
|
print '*** Application: %s' % c.root()['Application']
|
||||||
|
c.close()
|
||||||
|
reactor.callLater(5, show_application, db)
|
Loading…
Add table
Reference in a new issue