[Zodb-checkins] CVS: Zope3/src/zodb/code - class_.py:1.17 patch.py:1.11

Jeremy Hylton jeremy at zope.com
Wed May 7 15:19:38 EDT 2003


Update of /cvs-repository/Zope3/src/zodb/code
In directory cvs.zope.org:/tmp/cvs-serv26450

Modified Files:
	class_.py patch.py 
Log Message:
Fix class patch problem reported by Paolo Invernizzi.

A bunch of small, complex fixes are involved.

MethodMixin needs to handle SimpleDescriptor missing value.
Ignore _p_oid and _p_jar in _p_newstate() for classes.
Ignore "empty" descriptors in persistent_id(), where an
   empty descr is returned when a class has no value
   associated with the descr.
Add test that create instances of persistent classes
   from other modules.


=== Zope3/src/zodb/code/class_.py 1.16 => 1.17 ===
--- Zope3/src/zodb/code/class_.py:1.16	Sat May  3 12:29:37 2003
+++ Zope3/src/zodb/code/class_.py	Wed May  7 14:19:07 2003
@@ -93,6 +93,10 @@
 class MethodMixin:
 
     def __init__(self, name, descr, func):
+        if not hasattr(descr, "__get__"):
+            # If the object defined in the metaclass is not a descriptor,
+            # create one for it.
+            descr = SimpleDescriptor(descr)
         super(MethodMixin, self).__init__(name, descr)
         self.func = func
 
@@ -402,12 +406,23 @@
         # Update a class's __dict__ in place.  Must use setattr and
         # delattr because __dict__ is a read-only proxy.
         # XXX This doesn't handle __methods__ correctly.
+
+        # XXX I'm not sure how this is supposed to handle the
+        # ExtClassDataDescrs.  As a hack, I'm deleting _p_oid
+        # and _p_jar from the keys dict, because I know they
+        # will be descrs and they won't change as a result of
+        # update.  It appears that if the new class has a descr
+        # that isn't set on the class, it will stomp on the old
+        # class's value.  Not sure if this is a problem in general.
+        
         def getkeys(cls):
             L = [n for n in cls.__dict__.keys()
                  if not (n.startswith("__") and n.endswith("__"))]
             d = {}
             for elt in L:
                 d[elt] = True
+            del d["_p_oid"]
+            del d["_p_jar"]
             return d
         oldnames = getkeys(cls)
         newnames = getkeys(acls)
@@ -416,3 +431,4 @@
                 delattr(cls, name)
         for name in newnames:
             setattr(cls, name, acls.__dict__[name])
+


=== Zope3/src/zodb/code/patch.py 1.10 => 1.11 ===
--- Zope3/src/zodb/code/patch.py:1.10	Sat May  3 12:32:21 2003
+++ Zope3/src/zodb/code/patch.py	Wed May  7 14:19:07 2003
@@ -217,6 +217,9 @@
             elif oid is None:
                 # It's a persistent object, but it's newly created.
                 oid = object()
+            descr = getattr(oid, "__get__", None)
+            if descr is not None:
+                return None
             self._pmemo[oid] = obj
             return oid
 




More information about the Zodb-checkins mailing list