[Zodb-checkins] CVS: Zope3/src/zope/interface -
_callableimplements.py:1.2
Jim Fulton
jim at zope.com
Sat May 3 13:35:14 EDT 2003
Update of /cvs-repository/Zope3/src/zope/interface
In directory cvs.zope.org:/tmp/cvs-serv24124/src/zope/interface
Added Files:
_callableimplements.py
Log Message:
Provide a callable replacement for the zope.interfaces.implements
module so that we can use zope.interfaces.implements as *both*
the old module *and* the new API function.
=== Zope3/src/zope/interface/_callableimplements.py 1.1 => 1.2 ===
--- /dev/null Sat May 3 12:35:14 2003
+++ Zope3/src/zope/interface/_callableimplements.py Sat May 3 12:35:14 2003
@@ -0,0 +1,37 @@
+##############################################################################
+#
+# Copyright (c) 2003 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (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.
+#
+##############################################################################
+"""Hack^H^H^Hook up zope.interface.implements as a callable module.
+
+$Id$
+"""
+import sys
+import zope.interface.implements
+from zope.interface.declarations import _implements, ImplementsSpecification
+
+Module = sys.__class__
+
+class ImplementsModule:
+
+ def __init__(self):
+ self.__dict__.update(sys.modules['zope.interface.implements'].__dict__)
+
+ def __call__(self, *interfaces):
+ return _implements("implements", ImplementsSpecification(*interfaces))
+
+def hookup():
+ global _old
+ _old = sys.modules['zope.interface.implements']
+ sys.modules['zope.interface.implements'] = ImplementsModule()
+
+
More information about the Zodb-checkins
mailing list