[Zope3-checkins] CVS: Zope3/src/zope/context - __init__.py:1.22
Steve Alexander
steve@cat-box.net
Tue, 10 Jun 2003 08:53:15 -0400
Update of /cvs-repository/Zope3/src/zope/context
In directory cvs.zope.org:/tmp/cvs-serv8650/src/zope/context
Modified Files:
__init__.py
Log Message:
Simplified dealing with circular dependency between ContextAware and
ContextAwareMetaClass.
=== Zope3/src/zope/context/__init__.py 1.21 => 1.22 ===
--- Zope3/src/zope/context/__init__.py:1.21 Sat Jun 7 15:05:20 2003
+++ Zope3/src/zope/context/__init__.py Tue Jun 10 08:53:14 2003
@@ -121,30 +121,23 @@
def __delete__(self, inst):
self.descriptor.__delete__(inst)
-
+ContextAware = None # this will be replaced a few lines down
class ContextAwareMetaClass(type):
def __init__(self, name, bases, namespace):
- # stub
+ if ContextAware in bases:
+ for name, obj in namespace.items():
+ if not isinstance(obj, ContextDescriptor):
+ if getattr(obj, '__set__', None) is not None:
+ d = ContextAwareDataDescriptor(obj)
+ setattr(self, name, d)
+ namespace[name] = d
+ elif getattr(obj, '__get__', None) is not None:
+ m = ContextAwareDescriptor(obj)
+ setattr(self, name, m)
+ namespace[name] = m
super(ContextAwareMetaClass, self).__init__(name, bases, namespace)
-
class ContextAware:
__metaclass__ = ContextAwareMetaClass
-
-def init_method(self, name, bases, namespace):
- if ContextAware in bases:
- for name, obj in namespace.items():
- if not isinstance(obj, ContextDescriptor):
- if getattr(obj, '__set__', None) is not None:
- d = ContextAwareDataDescriptor(obj)
- setattr(self, name, d)
- namespace[name] = d
- elif getattr(obj, '__get__', None) is not None:
- m = ContextAwareDescriptor(obj)
- setattr(self, name, m)
- namespace[name] = m
- super(ContextAwareMetaClass, self).__init__(name, bases, namespace)
-ContextAwareMetaClass.__init__ = init_method
-del init_method