[Checkins] SVN: five.dbevent/ initial import

Jean-Francois Roche jfroche at jfroche.be
Tue Jan 12 11:03:07 EST 2010


Log message for revision 108063:
  initial import

Changed:
  A   five.dbevent/
  A   five.dbevent/trunk/
  A   five.dbevent/trunk/MANIFEST.in
  A   five.dbevent/trunk/README.txt
  A   five.dbevent/trunk/bootstrap.py
  A   five.dbevent/trunk/buildout.cfg
  A   five.dbevent/trunk/docs/
  A   five.dbevent/trunk/docs/HISTORY.txt
  A   five.dbevent/trunk/setup.py
  A   five.dbevent/trunk/src/
  A   five.dbevent/trunk/src/five/
  A   five.dbevent/trunk/src/five/__init__.py
  A   five.dbevent/trunk/src/five/dbevent/
  A   five.dbevent/trunk/src/five/dbevent/__init__.py
  A   five.dbevent/trunk/src/five/dbevent/configure.zcml

-=-
Added: five.dbevent/trunk/MANIFEST.in
===================================================================
--- five.dbevent/trunk/MANIFEST.in	                        (rev 0)
+++ five.dbevent/trunk/MANIFEST.in	2010-01-12 16:03:06 UTC (rev 108063)
@@ -0,0 +1,2 @@
+recursive-include docs *
+recursive-include src *

Added: five.dbevent/trunk/README.txt
===================================================================
--- five.dbevent/trunk/README.txt	                        (rev 0)
+++ five.dbevent/trunk/README.txt	2010-01-12 16:03:06 UTC (rev 108063)
@@ -0,0 +1,17 @@
+five.dbevent
+============
+
+Backport the notification of ``DatabaseOpenedWithRoot`` event to Zope 2.
+
+This might be useful to initialize components once the zope database is ready (see also ``zope.app.generations``)
+
+Install
+-------
+
+As its setup is done with ``collective.monkeypatcher``, you need to include ``five.dbevent`` configure.zcml
+
+Implementation
+--------------
+
+The package adds an ``__init__`` method to ``Zope2.App.startup.TransactionsManager``. It sends the ``DatabaseOpenedWithRoot`` event when
+the ``TransactionsManager`` is instantiated. This happens just after the initialization of the root folder (see ``Zope2.App.startup.startup``).

Added: five.dbevent/trunk/bootstrap.py
===================================================================
--- five.dbevent/trunk/bootstrap.py	                        (rev 0)
+++ five.dbevent/trunk/bootstrap.py	2010-01-12 16:03:06 UTC (rev 108063)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id: bootstrap.py 1090 2007-10-18 11:23:17Z jfroche $
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+ez = {}
+exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+                     ).read() in ez
+ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+import pkg_resources
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+if sys.platform == 'win32':
+    cmd = '"%s"' % cmd # work around spawn lamosity on windows
+
+ws = pkg_resources.working_set
+assert os.spawnle(
+    os.P_WAIT, sys.executable, sys.executable,
+    '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
+    dict(os.environ,
+         PYTHONPATH=
+         ws.find(pkg_resources.Requirement.parse('setuptools')).location
+         ),
+    ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout')
+import zc.buildout.buildout
+zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
+shutil.rmtree(tmpeggs)

Added: five.dbevent/trunk/buildout.cfg
===================================================================
--- five.dbevent/trunk/buildout.cfg	                        (rev 0)
+++ five.dbevent/trunk/buildout.cfg	2010-01-12 16:03:06 UTC (rev 108063)
@@ -0,0 +1,25 @@
+[buildout]
+parts =
+    zope2
+    instance
+    omelette
+develop =
+    .
+prefer-final = true
+
+[zope2]
+recipe = plone.recipe.zope2install
+url = http://www.zope.org/Products/Zope/2.11.4/Zope-2.11.4-final.tgz
+
+[instance]
+recipe = plone.recipe.zope2instance
+zope2-location = ${zope2:location}
+user = admin:admin
+http-address = 8080
+eggs = five.dbevent
+zcml = five.dbevent
+
+[omelette]
+recipe = collective.recipe.omelette
+eggs = ${instance:eggs}
+packages = ${zope2:location}/lib/python ./

Added: five.dbevent/trunk/docs/HISTORY.txt
===================================================================
--- five.dbevent/trunk/docs/HISTORY.txt	                        (rev 0)
+++ five.dbevent/trunk/docs/HISTORY.txt	2010-01-12 16:03:06 UTC (rev 108063)
@@ -0,0 +1,8 @@
+Changelog
+=========
+
+0.1 - Unreleased
+----------------
+
+* Initial release
+

Added: five.dbevent/trunk/setup.py
===================================================================
--- five.dbevent/trunk/setup.py	                        (rev 0)
+++ five.dbevent/trunk/setup.py	2010-01-12 16:03:06 UTC (rev 108063)
@@ -0,0 +1,31 @@
+from setuptools import setup, find_packages
+import os
+
+version = '0.1'
+
+setup(name='five.dbevent',
+      version=version,
+      description="Database startup events",
+      long_description=open("README.txt").read() + "\n" +
+                       open(os.path.join("docs", "HISTORY.txt")).read(),
+      classifiers=[
+        "Programming Language :: Python",
+        "Topic :: Software Development :: Libraries :: Python Modules",
+        ],
+      keywords='',
+      author='Godefroid Chapelle and Jean-Francois Roche',
+      author_email='',
+      url='http://pypi.python.org/pypi/five.dbevent',
+      license='GPL',
+      packages=find_packages('src', exclude=['ez_setup']),
+      package_dir={'': 'src'},
+      namespace_packages=['five'],
+      include_package_data=True,
+      zip_safe=False,
+      install_requires=[
+          'setuptools',
+          'collective.monkeypatcher'],
+      entry_points="""
+      # -*- Entry points: -*-
+      """,
+      )

Added: five.dbevent/trunk/src/five/__init__.py
===================================================================
--- five.dbevent/trunk/src/five/__init__.py	                        (rev 0)
+++ five.dbevent/trunk/src/five/__init__.py	2010-01-12 16:03:06 UTC (rev 108063)
@@ -0,0 +1,6 @@
+# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
+try:
+    __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+    from pkgutil import extend_path
+    __path__ = extend_path(__path__, __name__)

Added: five.dbevent/trunk/src/five/dbevent/__init__.py
===================================================================
--- five.dbevent/trunk/src/five/dbevent/__init__.py	                        (rev 0)
+++ five.dbevent/trunk/src/five/dbevent/__init__.py	2010-01-12 16:03:06 UTC (rev 108063)
@@ -0,0 +1,18 @@
+import logging
+import Zope2
+from zope.app.appsetup.interfaces import (DatabaseOpenedWithRoot,
+                                          IDatabaseOpenedWithRootEvent)
+from zope.event import notify
+from zope.component import provideHandler
+
+
+def notifyDBEvent(self):
+    notify(DatabaseOpenedWithRoot(Zope2.DB))
+
+
+def logToDbEvent(event):
+    db = event.database
+    log = logging.getLogger('Zope')
+    log.info('%s zodb database opened with root' % db.database_name)
+
+provideHandler(logToDbEvent, [IDatabaseOpenedWithRootEvent])

Added: five.dbevent/trunk/src/five/dbevent/configure.zcml
===================================================================
--- five.dbevent/trunk/src/five/dbevent/configure.zcml	                        (rev 0)
+++ five.dbevent/trunk/src/five/dbevent/configure.zcml	2010-01-12 16:03:06 UTC (rev 108063)
@@ -0,0 +1,17 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+           xmlns:monkey="http://namespaces.plone.org/monkey"
+           i18n_domain="five.dbevent">
+
+  <include package="collective.monkeypatcher" file="meta.zcml" />
+
+  <monkey:patch
+    description=""
+    class="Zope2.App.startup.TransactionsManager"
+    replacement=".notifyDBEvent"
+    original="__init__"
+    docstringWarning="false"
+    ignoreOriginal="true"
+    />
+
+</configure>
+



More information about the checkins mailing list