[Zope3-checkins] CVS: Zope3/src/zodb/code - class_.py:1.22 function.py:1.7 module.py:1.19 patch.py:1.15

Fred L. Drake, Jr. fred at zope.com
Fri Feb 20 11:58:06 EST 2004


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

Modified Files:
	class_.py function.py module.py patch.py 
Log Message:


update to replace ZODB 4 with ZODB 3


=== Zope3/src/zodb/code/class_.py 1.21 => 1.22 ===
--- Zope3/src/zodb/code/class_.py:1.21	Wed Oct 29 14:32:50 2003
+++ Zope3/src/zodb/code/class_.py	Fri Feb 20 11:57:03 2004
@@ -16,8 +16,7 @@
 __metaclass__ = type
 
 from zope.interface import implements
-from persistence import PersistentMetaClass
-from persistence._persistence import UPTODATE, CHANGED, GHOST
+from persistent.cPersistence import UPTODATE, CHANGED, GHOST
 from persistence.interfaces import IPersistent
 from zodb.code.function import PersistentFunction
 
@@ -214,7 +213,7 @@
     # A data descriptor for _p_changed.
     pass
 
-class PersistentClassMetaClass(PersistentMetaClass):
+class PersistentClassMetaClass(type):
 
     # An attempt to make persistent classes look just like other
     # persistent objects by providing class attributes and methods
@@ -264,6 +263,7 @@
         extend_attr("_p_changed", None)
         extend_meth("_p_activate", meta._p_activate)
         extend_meth("_p_deactivate", meta._p_deactivate)
+        # XXX _p_invalidate
 
         # Create a descriptor that calls _p_activate() when _p_jar is set.
         inst_jar_descr = findattr(cls, "_p_jar", None)
@@ -383,7 +383,7 @@
                 try:
                     # XXX Make sure the object is in the cache before
                     # calling setstate().
-                    dm._cache.set(cls._p_oid, cls)
+                    dm._cache[cls._p_oid] = cls
                     dm.setstate(cls)
                 finally:
                     # XXX Should really put in special inconsistent state
@@ -419,12 +419,12 @@
         
         def getkeys(cls):
             L = [n for n in cls.__dict__.keys()
-                 if not (n.startswith("__") and n.endswith("__"))]
+                 if (not (n.startswith("__") and n.endswith("__"))
+                     and not n.startswith("_p_"))
+                 ]
             d = {}
             for elt in L:
                 d[elt] = True
-            del d["_p_oid"]
-            del d["_p_jar"]
             return d
         oldnames = getkeys(cls)
         newnames = getkeys(acls)


=== Zope3/src/zodb/code/function.py 1.6 => 1.7 ===
--- Zope3/src/zodb/code/function.py:1.6	Tue May 20 15:07:23 2003
+++ Zope3/src/zodb/code/function.py	Fri Feb 20 11:57:03 2004
@@ -103,6 +103,8 @@
     def __getattr__(self, attr):
         # If it wasn't found in __dict__, then it must be a function
         # attribute.
+        if attr == '_pf_func':
+            raise AttributeError, attr
         return getattr(self._pf_func, attr)
 
     def __setattr__(self, attr, value):
@@ -115,6 +117,8 @@
                     self._v_side_effect = has_side_effect(self._pf_func)
             else:
                 setattr(self._pf_func, attr, value)
+            if not attr.startswith('_v_'):
+                self._p_changed = 1
 
     def __delattr__(self, attr):
         if not self._p_delattr(attr):
@@ -124,6 +128,8 @@
                 del self.__dict__[attr]
             else:
                 delattr(self._pf_func, attr)
+            if not attr.startswith('_v_'):
+                self._p_changed = 1
 
     def __call__(self, *args, **kwargs):
         # We must make sure that _module is loaded when func is


=== Zope3/src/zodb/code/module.py 1.18 => 1.19 ===
--- Zope3/src/zodb/code/module.py:1.18	Mon Nov 10 13:49:56 2003
+++ Zope3/src/zodb/code/module.py	Fri Feb 20 11:57:03 2004
@@ -17,8 +17,8 @@
 
 from zope.interface import implements
 
-from persistence import Persistent
-from persistence._persistence import GHOST
+from persistent import Persistent
+from persistent.cPersistence import GHOST
 from zodb.code.interfaces import IPersistentModuleManager
 from zodb.code.interfaces \
      import IPersistentModuleImportRegistry, IPersistentModuleUpdateRegistry
@@ -219,14 +219,17 @@
     # sys.modules, because each registry could have a different binding
     # for a particular name.
 
-    def __init__(self):
-        self._saved_import = None
+    _saved_import = None
 
     def install(self):
+        if self._saved_import is not None:
+            raise TypeError("Already installed!")
         self._saved_import = __builtin__.__import__
         __builtin__.__import__ = self.__import__
 
     def uninstall(self):
+        if self._saved_import is None:
+            raise TypeError("Not installed!")
         __builtin__.__import__ = self._saved_import
 
     def _import(self, registry, name, parent, fromlist):
@@ -292,7 +295,7 @@
         self._modules = {}
 
     def findModule(self, name):
-        assert self._p_state != GHOST
+        assert self._p_changed is not None
         return self._modules.get(name)
 
     def setModule(self, name, module):


=== Zope3/src/zodb/code/patch.py 1.14 => 1.15 ===
--- Zope3/src/zodb/code/patch.py:1.14	Mon Nov  3 16:43:29 2003
+++ Zope3/src/zodb/code/patch.py	Fri Feb 20 11:57:03 2004
@@ -93,7 +93,6 @@
 
 from zodb.code.class_ import PersistentClassMetaClass, PersistentDescriptor
 from zodb.code.function import PersistentFunction
-from persistence import PersistentMetaClass
 
 class Wrapper:
     """Implement pickling reduce protocol for update-able object.
@@ -239,7 +238,7 @@
 
     dispatch[TypeType] = save_type
     dispatch[ClassType] = save_type
-    dispatch[PersistentMetaClass] = save_type
+    dispatch[type] = save_type
     dispatch[PersistentClassMetaClass] = save_type
 
     def save_function(self, func):




More information about the Zope3-Checkins mailing list