[Checkins] SVN: lovely.memcached/trunk/s add configurator
Bernd Dorn
bernd.dorn at lovelysystems.com
Mon Apr 2 10:52:58 EDT 2007
Log message for revision 73982:
add configurator
Changed:
U lovely.memcached/trunk/setup.py
_U lovely.memcached/trunk/src/lovely/memcached/browser/
U lovely.memcached/trunk/src/lovely/memcached/browser/tests.py
A lovely.memcached/trunk/src/lovely/memcached/configurator.py
U lovely.memcached/trunk/src/lovely/memcached/configure.zcml
U lovely.memcached/trunk/src/lovely/memcached/utility.py
-=-
Modified: lovely.memcached/trunk/setup.py
===================================================================
--- lovely.memcached/trunk/setup.py 2007-04-02 13:12:52 UTC (rev 73981)
+++ lovely.memcached/trunk/setup.py 2007-04-02 14:52:58 UTC (rev 73982)
@@ -17,7 +17,9 @@
extras_require = dict(test = ['zope.app.testing',
'zope.app.securitypolicy',
'zope.app.zcmlfiles',
- 'zope.testbrowser']),
+ 'zope.testbrowser',
+ 'z3c.testing',
+ 'z3c.configurator']),
install_requires = ['setuptools',
'python-memcached',
'ZODB3',
Property changes on: lovely.memcached/trunk/src/lovely/memcached/browser
___________________________________________________________________
Name: svn:ignore
+ var_*
Modified: lovely.memcached/trunk/src/lovely/memcached/browser/tests.py
===================================================================
--- lovely.memcached/trunk/src/lovely/memcached/browser/tests.py 2007-04-02 13:12:52 UTC (rev 73981)
+++ lovely.memcached/trunk/src/lovely/memcached/browser/tests.py 2007-04-02 14:52:58 UTC (rev 73982)
@@ -19,9 +19,17 @@
import unittest
from zope.testing import doctest
from zope.app.testing import functional
+from z3c.testing import layer
+from z3c.configurator import configurator
-functional.defineLayer('MemcachedLayer', 'ftesting.zcml')
+def appSetUp(app):
+ configurator.configure(app, {},
+ names = ['lovely.memcachedclient'])
+layer.defineLayer('MemcachedLayer', zcml='ftesting.zcml',
+ appSetUp=appSetUp,
+ clean=True)
+
def test_suite():
suite = functional.FunctionalDocFileSuite('README.txt')
suite.layer = MemcachedLayer
Added: lovely.memcached/trunk/src/lovely/memcached/configurator.py
===================================================================
--- lovely.memcached/trunk/src/lovely/memcached/configurator.py 2007-04-02 13:12:52 UTC (rev 73981)
+++ lovely.memcached/trunk/src/lovely/memcached/configurator.py 2007-04-02 14:52:58 UTC (rev 73982)
@@ -0,0 +1,44 @@
+##############################################################################
+#
+# Copyright (c) 2007 Lovely Systems 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.
+#
+##############################################################################
+"""
+$Id$
+"""
+__docformat__ = "reStructuredText"
+
+import interfaces
+import utility
+from zope import component
+from z3c.configurator import configurator
+from zope.app.component.interfaces import ISite
+from zope.lifecycleevent import ObjectCreatedEvent
+import zope.event
+from zope.security.proxy import removeSecurityProxy
+
+class SetUpMemcachedClient(configurator.ConfigurationPluginBase):
+ component.adapts(ISite)
+
+ def __call__(self, data):
+ site = self.context
+ # we just wanna have one
+ util = component.queryUtility(interfaces.IMemcachedClient,
+ context=site)
+ if util is not None:
+ return
+ # needed to be called TTW
+ sm = removeSecurityProxy(site.getSiteManager())
+ default = sm['default']
+ util = utility.MemcachedClient()
+ zope.event.notify(ObjectCreatedEvent(util))
+ default['memcachedclient'] = util
+ sm.registerUtility(util, interfaces.IMemcachedClient)
Property changes on: lovely.memcached/trunk/src/lovely/memcached/configurator.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: lovely.memcached/trunk/src/lovely/memcached/configure.zcml
===================================================================
--- lovely.memcached/trunk/src/lovely/memcached/configure.zcml 2007-04-02 13:12:52 UTC (rev 73981)
+++ lovely.memcached/trunk/src/lovely/memcached/configure.zcml 2007-04-02 14:52:58 UTC (rev 73982)
@@ -1,6 +1,6 @@
<configure
xmlns="http://namespaces.zope.org/zope"
- xmlns:browser="http://namespaces.zope.org/browser"
+ xmlns:zcml="http://namespaces.zope.org/zcml"
i18n_domain="zope"
>
@@ -20,6 +20,10 @@
/>
</class>
+ <adapter factory=".configurator.SetUpMemcachedClient"
+ zcml:condition="installed z3c.configurator"
+ name="lovely.memcachedclient"/>
+
<include package=".browser"/>
</configure>
Modified: lovely.memcached/trunk/src/lovely/memcached/utility.py
===================================================================
--- lovely.memcached/trunk/src/lovely/memcached/utility.py 2007-04-02 13:12:52 UTC (rev 73981)
+++ lovely.memcached/trunk/src/lovely/memcached/utility.py 2007-04-02 14:52:58 UTC (rev 73982)
@@ -89,6 +89,8 @@
def invalidateAll(self):
# notice this does not look at namespaces
self.client.flush_all()
+ if hasattr(self, '_v_storage'):
+ del self._v_storage
def _buildKey(self, key, ns):
More information about the Checkins
mailing list