From d021473fbf5840f866e0bd0b79109da9ddb53f0d Mon Sep 17 00:00:00 2001 From: helmutm Date: Sun, 16 Aug 2009 11:01:13 +0000 Subject: [PATCH] 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 --- twisted/z2/__init__.py | 4 ++++ twisted/z2/configure.zcml | 11 +++++++++++ twisted/z2/startup.py | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 twisted/z2/__init__.py create mode 100644 twisted/z2/configure.zcml create mode 100755 twisted/z2/startup.py diff --git a/twisted/z2/__init__.py b/twisted/z2/__init__.py new file mode 100644 index 0000000..4bc90fb --- /dev/null +++ b/twisted/z2/__init__.py @@ -0,0 +1,4 @@ +""" +$Id$ +""" + diff --git a/twisted/z2/configure.zcml b/twisted/z2/configure.zcml new file mode 100644 index 0000000..b027bd2 --- /dev/null +++ b/twisted/z2/configure.zcml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/twisted/z2/startup.py b/twisted/z2/startup.py new file mode 100755 index 0000000..5d6ab4b --- /dev/null +++ b/twisted/z2/startup.py @@ -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)