[Zope3-checkins] CVS: Zope3/lib/python/Zope/ContextWrapper - SimpleMethodWrapper.py:1.6.2.1

Jim Fulton jim@zope.com
Sat, 30 Nov 2002 07:44:32 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/ContextWrapper
In directory cvs.zope.org:/tmp/cvs-serv30047/lib/python/Zope/ContextWrapper

Modified Files:
      Tag: Zope3-Bangalore-TTW-Branch
	SimpleMethodWrapper.py 
Log Message:
Refactored the way TTW component registration is done.  There are now
separate registry objects that abstract the machinery for registering
multiple conflicting configurations and deciding which, if any are
active.  Also provided a new field and widget for the status
information.

Along the way, cleaned up and streamlined placeful testing
infrastructure a bit.

Now checking into branch. Will give file-by-file (or at least more
specific logs) when the changes are merged into the head.


=== Zope3/lib/python/Zope/ContextWrapper/SimpleMethodWrapper.py 1.6 => 1.6.2.1 ===
--- Zope3/lib/python/Zope/ContextWrapper/SimpleMethodWrapper.py:1.6	Tue Nov 12 10:55:58 2002
+++ Zope3/lib/python/Zope/ContextWrapper/SimpleMethodWrapper.py	Sat Nov 30 07:44:31 2002
@@ -36,7 +36,7 @@
 class ContextMethod:
     def __new__(cls, method):
         try:
-            method.__dict__['Zope.ContextWrapper.contextful_get'] = True
+            method.__Zope_ContextWrapper_contextful_get__ = True
         except AttributeError:
             raise TypeError(
                 "Cannot make %s into a contextmethod" % type(method)
@@ -47,21 +47,21 @@
 class ContextProperty(property):
     """A property that provides a context wrapper to its getter and setter
     methods"""
-    __dict__ = {'Zope.ContextWrapper.contextful_get': True,
-                'Zope.ContextWrapper.contextful_set': True}
+    __Zope_ContextWrapper_contextful_get__ = True
+    __Zope_ContextWrapper_contextful_set__ = True
 
 class ContextGetProperty(property):
     """A property that provides a context wrapper to its getter method"""
-    __dict__ = {'Zope.ContextWrapper.contextful_get': True}
+    __Zope_ContextWrapper_contextful_get__ = True
 
 class ContextSetProperty(property):
     """A property that provides a context wrapper to its setter method"""
-    __dict__ = {'Zope.ContextWrapper.contextful_set': True}
+    __Zope_ContextWrapper_contextful_set__ = True
 
 def wrapperCreator(object, context=None, **data):
     if hasattr(object, '__call__'):
-        attrdict = getattr(object.__call__, '__dict__', {})
-        if attrdict.get('Zope.ContextWrapper.contextful_get'):
+        if getattr(object.__call__,
+                   '__Zope_ContextWrapper_contextful_get__', 0):
             return SimpleCallableMethodWrapper(object, context, **data)
 
     return SimpleMethodWrapper(object, context, **data)
@@ -69,30 +69,28 @@
 
 class SimpleMethodWrapper(Wrapper):
 
-    def __getattribute__(self, name, empty_dict={},
-                         getbaseobject=getbaseobject):
+    def __getattribute__(self, name):
         """Support for ContextMethod and ContextProperty.__get__"""
         obj = getbaseobject(self)
         class_ = obj.__class__
         class_value = getattr(class_, name, None)
         if hasattr(class_value, '__get__'):
-            attrdict = getattr(class_value, '__dict__', empty_dict)
-            if attrdict.get('Zope.ContextWrapper.contextful_get'):
+            if getattr(class_value,
+                       '__Zope_ContextWrapper_contextful_get__', 0):
                 return class_value.__get__(self, class_)
             
         return Wrapper.__getattribute__(self, name)
 
 
 
-    def __setattr__(self, name, value, empty_dict={},
-                    getbaseobject=getbaseobject):
+    def __setattr__(self, name, value):
         """Support for ContextProperty.__set__"""
         obj = getbaseobject(self)
         class_ = obj.__class__
         class_value = getattr(class_, name, None)
-        if hasattr(class_value, '__get__'):
-            attrdict = getattr(class_value, '__dict__', empty_dict)
-            if attrdict.get('Zope.ContextWrapper.contextful_set'):
+        if hasattr(class_value, '__set__'):
+            if getattr(class_value,
+                       '__Zope_ContextWrapper_contextful_set__', 0):
                 class_value.__set__(self, value)
                 return
         setattr(obj, name, value)