[Zope-Checkins] SVN: Zope/trunk/lib/python/ Merge the Zope part of Zope/branches/jim-fix-zclasses.

Tim Peters tim.one at comcast.net
Wed Apr 6 23:49:30 EDT 2005


Log message for revision 29895:
  Merge the Zope part of Zope/branches/jim-fix-zclasses.
  
  Two of the ZClasses tests are disabled here, because they
  run afoul of Zope trunk's security machinery.  Jim needs to look
  at them.  A blurb also needs to be added to CHANGES.txt.
  
  Here are checkin msgs from the branch relating to Zope code
  (the msgs relating to ZODB code were reproduced in the
  ZODB 3.4 branch checkin):
  
      ------------------------------------------------------------------------
      r29869 | jim | 2005-04-04 07:04:21 -0400 (Mon, 04 Apr 2005) | 6 lines
      Changed paths:
         M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/ZClass.txt
  
      Added configuration of class factory.
  
      Use explicit tm for second connection rather than separate thread.
  
      Added copy test
  
      ------------------------------------------------------------------------
      r29868 | jim | 2005-04-04 07:03:57 -0400 (Mon, 04 Apr 2005) | 2 lines
      Changed paths:
         M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/_pmc.txt
  
      Added configuration of class factory.
  
      ------------------------------------------------------------------------
      r29776 | jim | 2005-04-01 06:24:31 -0500 (Fri, 01 Apr 2005) | 3 lines
      Changed paths:
         M /Zope/branches/jim-fix-zclasses/lib/python/OFS/tests/testProductInit.py
  
      Added clean-up code to remove non-exixtent directoris from products
      path.
  
      ------------------------------------------------------------------------
      r29775 | jim | 2005-04-01 06:24:29 -0500 (Fri, 01 Apr 2005) | 2 lines
      Changed paths:
         M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/tests.py
  
      Added missing abourt to tear-down code
  
      ------------------------------------------------------------------------
      r29772 | jim | 2005-04-01 06:24:22 -0500 (Fri, 01 Apr 2005) | 2 lines
      Changed paths:
         M /Zope/branches/jim-fix-zclasses/lib/python/App/ApplicationManager.py
         M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/Basic.py
         M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/ZClass.py
         M /Zope/branches/jim-fix-zclasses/lib/python/Zope2/App/startup.py
  
      Removed BoboPOS compatibility code.
  
      ------------------------------------------------------------------------
      r29201 | jim | 2005-02-18 07:18:05 -0500 (Fri, 18 Feb 2005) | 3 lines
      Changed paths:
         A /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/27.fs
         A /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/27.txt
         M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/tests.py
  
      Added a test for reading ZClasses and their instances from Zope 2.7
      databases.
  
      ------------------------------------------------------------------------
      r29149 | jim | 2005-02-15 07:24:49 -0500 (Tue, 15 Feb 2005) | 2 lines
      Changed paths:
         M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/ZClass.txt
         M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/tests.py
  
      Made the tests a bit more thorough.
  
      ------------------------------------------------------------------------
      r29148 | jim | 2005-02-15 07:24:44 -0500 (Tue, 15 Feb 2005) | 3 lines
      Changed paths:
         M /Zope/branches/jim-fix-zclasses/lib/python/OFS/tests/testAppInitializer.py
  
      Made the test cleanup more robust by cleaning up any non-existent
      directories found in Products.__path__.
  
      ------------------------------------------------------------------------
      r29147 | jim | 2005-02-15 07:24:37 -0500 (Tue, 15 Feb 2005) | 3 lines
      Changed paths:
         M /Zope/branches/jim-fix-zclasses/lib/python/ExtensionClass/ExtensionClass.h
         M /Zope/branches/jim-fix-zclasses/lib/python/ExtensionClass/_ExtensionClass.c
  
      Fixed code that assumed that there weren't subclasses of the
      ExtensionClass meta class.
  
      ------------------------------------------------------------------------
      r29136 | jim | 2005-02-13 11:37:33 -0500 (Sun, 13 Feb 2005) | 3 lines
      Changed paths:
         M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/ZClass.py
         M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/ZClass.txt
         M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/_pmc.py
         M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/tests.py
  
      Integrated persistent metaclass with ZClasses and got basic ZClass
      test to pass.
  
      ------------------------------------------------------------------------
      r29135 | jim | 2005-02-13 11:15:15 -0500 (Sun, 13 Feb 2005) | 3 lines
      Changed paths:
         M /Zope/branches/jim-fix-zclasses/lib/python/ExtensionClass/_ExtensionClass.c
         M /Zope/branches/jim-fix-zclasses/lib/python/ExtensionClass/tests.py
  
      Fixed bug in Base __getattro__ that caused __of__ to be missed in
      instances of instances of subclasses (meta classes) of ExtensionClass.
  
      ------------------------------------------------------------------------
      r29072 | jim | 2005-02-07 07:36:07 -0500 (Mon, 07 Feb 2005) | 5 lines
      Changed paths:
         M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/Property.py
         M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/ZClass.py
  
      Fixed some code for registering class changes to avoid the
      registration of data managers that are None.  This code will,
      eventually, go away, since new persistent classes will
      take care of their own registration.
  
      ------------------------------------------------------------------------
      r29070 | jim | 2005-02-07 07:36:03 -0500 (Mon, 07 Feb 2005) | 3 lines
      Changed paths:
         A /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/ZClass.txt
  
      Created a basic ZClass test. It still isn't used, because the
      persistent meta class hasn't been integrated yet.
  
      ------------------------------------------------------------------------
      r29069 | jim | 2005-02-07 07:36:01 -0500 (Mon, 07 Feb 2005) | 3 lines
      Changed paths:
         A /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/_pmc.py
         A /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/_pmc.txt
         A /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/tests.py
  
      Created a meta class for persistent classes.  This is based very
      loosly on the experimental persistent class code from Zope 3.
  
      ------------------------------------------------------------------------
      r29068 | jim | 2005-02-07 07:35:58 -0500 (Mon, 07 Feb 2005) | 2 lines
      Changed paths:
         M /Zope/branches/jim-fix-zclasses/lib/python/ExtensionClass/_ExtensionClass.c
  
      Made the ExtensionClass meta class subclassible.
  
      ------------------------------------------------------------------------
      r29065 | jim | 2005-02-07 07:35:52 -0500 (Mon, 07 Feb 2005) | 3 lines
      Changed paths:
         M /Zope/branches/jim-fix-zclasses/lib/python/OFS/tests/testAppInitializer.py
  
      Added missing cleanup code to return Products.__path__ to it's
      original state.
  

Changed:
  U   Zope/trunk/lib/python/AccessControl/tests/testZopeSecurityPolicy.py
  U   Zope/trunk/lib/python/Acquisition/tests.py
  U   Zope/trunk/lib/python/App/ApplicationManager.py
  U   Zope/trunk/lib/python/ComputedAttribute/tests.py
  U   Zope/trunk/lib/python/ExtensionClass/ExtensionClass.h
  U   Zope/trunk/lib/python/ExtensionClass/_ExtensionClass.c
  U   Zope/trunk/lib/python/ExtensionClass/tests.py
  U   Zope/trunk/lib/python/MethodObject/tests.py
  U   Zope/trunk/lib/python/Missing/tests.py
  U   Zope/trunk/lib/python/MultiMapping/tests.py
  U   Zope/trunk/lib/python/OFS/tests/testAppInitializer.py
  U   Zope/trunk/lib/python/OFS/tests/testProductInit.py
  U   Zope/trunk/lib/python/ThreadLock/tests.py
  A   Zope/trunk/lib/python/ZClasses/27.fs
  A   Zope/trunk/lib/python/ZClasses/27.txt
  U   Zope/trunk/lib/python/ZClasses/Basic.py
  U   Zope/trunk/lib/python/ZClasses/Property.py
  U   Zope/trunk/lib/python/ZClasses/ZClass.py
  A   Zope/trunk/lib/python/ZClasses/ZClass.txt
  A   Zope/trunk/lib/python/ZClasses/_pmc.py
  A   Zope/trunk/lib/python/ZClasses/_pmc.txt
  A   Zope/trunk/lib/python/ZClasses/tests.py
  U   Zope/trunk/lib/python/ZPublisher/tests/testPublish.py
  U   Zope/trunk/lib/python/Zope2/App/startup.py

-=-
Modified: Zope/trunk/lib/python/AccessControl/tests/testZopeSecurityPolicy.py
===================================================================
--- Zope/trunk/lib/python/AccessControl/tests/testZopeSecurityPolicy.py	2005-04-07 01:14:11 UTC (rev 29894)
+++ Zope/trunk/lib/python/AccessControl/tests/testZopeSecurityPolicy.py	2005-04-07 03:49:30 UTC (rev 29895)
@@ -495,7 +495,7 @@
     
     """
 
-from doctest import DocTestSuite
+from zope.testing.doctest import DocTestSuite
 
 def test_suite():
     suite = unittest.TestSuite()

Modified: Zope/trunk/lib/python/Acquisition/tests.py
===================================================================
--- Zope/trunk/lib/python/Acquisition/tests.py	2005-04-07 01:14:11 UTC (rev 29894)
+++ Zope/trunk/lib/python/Acquisition/tests.py	2005-04-07 03:49:30 UTC (rev 29895)
@@ -1527,7 +1527,7 @@
     
 
 import unittest
-from doctest import DocTestSuite
+from zope.testing.doctest import DocTestSuite
 
 def test_suite():
     return unittest.TestSuite((

Modified: Zope/trunk/lib/python/App/ApplicationManager.py
===================================================================
--- Zope/trunk/lib/python/App/ApplicationManager.py	2005-04-07 01:14:11 UTC (rev 29894)
+++ Zope/trunk/lib/python/App/ApplicationManager.py	2005-04-07 03:49:30 UTC (rev 29895)
@@ -376,11 +376,9 @@
         return self._p_jar.db().getName()
 
     def db_size(self):
-        if Globals.DatabaseVersion=='2':
-            s=os.stat(self.db_name())[6]
-        else:
-            s=self._p_jar.db().getSize()
-            if type(s) is type(''): return s
+        s=self._p_jar.db().getSize()
+        if type(s) is type(''):
+            return s
 
         if s >= 1048576.0: return '%.1fM' % (s/1048576.0)
         return '%.1fK' % (s/1024.0)

Modified: Zope/trunk/lib/python/ComputedAttribute/tests.py
===================================================================
--- Zope/trunk/lib/python/ComputedAttribute/tests.py	2005-04-07 01:14:11 UTC (rev 29894)
+++ Zope/trunk/lib/python/ComputedAttribute/tests.py	2005-04-07 03:49:30 UTC (rev 29895)
@@ -66,7 +66,7 @@
     """
 
 import unittest
-from doctest import DocTestSuite
+from zope.testing.doctest import DocTestSuite
 from ExtensionClass import Base
 from ComputedAttribute import ComputedAttribute
 

Modified: Zope/trunk/lib/python/ExtensionClass/ExtensionClass.h
===================================================================
--- Zope/trunk/lib/python/ExtensionClass/ExtensionClass.h	2005-04-07 01:14:11 UTC (rev 29894)
+++ Zope/trunk/lib/python/ExtensionClass/ExtensionClass.h	2005-04-07 03:49:30 UTC (rev 29895)
@@ -175,11 +175,11 @@
 
 /* The following macro checks whether a type is an extension class: */
 #define PyExtensionClass_Check(TYPE) \
-  (((PyObject*)(TYPE))->ob_type == ECExtensionClassType)
+  PyObject_TypeCheck((PyObject*)(TYPE), ECExtensionClassType)
 
 /* The following macro checks whether an instance is an extension instance: */
 #define PyExtensionInstance_Check(INST) \
-  (((PyObject*)(INST))->ob_type->ob_type == ECExtensionClassType)
+  PyObject_TypeCheck(((PyObject*)(INST))->ob_type, ECExtensionClassType)
 
 #define CHECK_FOR_ERRORS(MESS) 
 
@@ -213,7 +213,7 @@
 
 /* Check whether an object has an __of__ method for returning itself
    in the context of it's container. */
-#define has__of__(O) ((O)->ob_type->ob_type == ECExtensionClassType \
+#define has__of__(O) (PyObject_TypeCheck((O)->ob_type, ECExtensionClassType) \
                       && (O)->ob_type->tp_descr_get != NULL)
 
 /* The following macros are used to check whether an instance

Modified: Zope/trunk/lib/python/ExtensionClass/_ExtensionClass.c
===================================================================
--- Zope/trunk/lib/python/ExtensionClass/_ExtensionClass.c	2005-04-07 01:14:11 UTC (rev 29894)
+++ Zope/trunk/lib/python/ExtensionClass/_ExtensionClass.c	2005-04-07 03:49:30 UTC (rev 29895)
@@ -142,7 +142,8 @@
                              If the tp_descr_get of res is of_get, 
                              then call it. */
 
-                          if (res->ob_type->ob_type == &ExtensionClassType
+                          if (PyObject_TypeCheck(res->ob_type,
+                                                 &ExtensionClassType)
                               && res->ob_type->tp_descr_get != NULL)
                             res = res->ob_type->tp_descr_get(
                                                  res, obj, 
@@ -603,6 +604,7 @@
         /* tp_as_buffer      */ 0,
         /* tp_flags          */ Py_TPFLAGS_DEFAULT
                                 | Py_TPFLAGS_HAVE_GC
+                                | Py_TPFLAGS_BASETYPE
                                 ,
 	/* tp_doc            */ "Meta-class for extension classes",
         /* tp_traverse       */ (traverseproc)0,

Modified: Zope/trunk/lib/python/ExtensionClass/tests.py
===================================================================
--- Zope/trunk/lib/python/ExtensionClass/tests.py	2005-04-07 01:14:11 UTC (rev 29894)
+++ Zope/trunk/lib/python/ExtensionClass/tests.py	2005-04-07 03:49:30 UTC (rev 29895)
@@ -709,7 +709,35 @@
 
     """
 
-from doctest import DocTestSuite
+def test___of___w_metaclass_instance():
+    """When looking for extension class instances, need to handle meta classes
+
+    >>> class C(Base):
+    ...     pass
+
+    >>> class O(Base):
+    ...     def __of__(self, parent):
+    ...         print '__of__ called on an O'
+
+    >>> class M(ExtensionClass):
+    ...     pass
+
+    >>> class X:
+    ...     __metaclass__ = M
+    ...     
+
+    >>> class S(X, O):
+    ...     pass
+
+    >>> c = C()
+    >>> c.s = S()
+    >>> c.s
+    __of__ called on an O
+
+    """
+
+
+from zope.testing.doctest import DocTestSuite
 import unittest
 
 def test_suite():

Modified: Zope/trunk/lib/python/MethodObject/tests.py
===================================================================
--- Zope/trunk/lib/python/MethodObject/tests.py	2005-04-07 01:14:11 UTC (rev 29894)
+++ Zope/trunk/lib/python/MethodObject/tests.py	2005-04-07 03:49:30 UTC (rev 29895)
@@ -16,7 +16,7 @@
 $Id$
 """
 import unittest
-from doctest import DocTestSuite
+from zope.testing.doctest import DocTestSuite
 
 def test_xxx():
     """

Modified: Zope/trunk/lib/python/Missing/tests.py
===================================================================
--- Zope/trunk/lib/python/Missing/tests.py	2005-04-07 01:14:11 UTC (rev 29894)
+++ Zope/trunk/lib/python/Missing/tests.py	2005-04-07 03:49:30 UTC (rev 29895)
@@ -36,7 +36,7 @@
 $Id$
 """
 import unittest
-from doctest import DocTestSuite
+from zope.testing.doctest import DocTestSuite
 
 def test_suite():
     return unittest.TestSuite((

Modified: Zope/trunk/lib/python/MultiMapping/tests.py
===================================================================
--- Zope/trunk/lib/python/MultiMapping/tests.py	2005-04-07 01:14:11 UTC (rev 29894)
+++ Zope/trunk/lib/python/MultiMapping/tests.py	2005-04-07 03:49:30 UTC (rev 29895)
@@ -50,7 +50,7 @@
 $Id$
 """
 import unittest
-from doctest import DocTestSuite
+from zope.testing.doctest import DocTestSuite
 
 def test_suite():
     return unittest.TestSuite((

Modified: Zope/trunk/lib/python/OFS/tests/testAppInitializer.py
===================================================================
--- Zope/trunk/lib/python/OFS/tests/testAppInitializer.py	2005-04-07 01:14:11 UTC (rev 29894)
+++ Zope/trunk/lib/python/OFS/tests/testAppInitializer.py	2005-04-07 03:49:30 UTC (rev 29895)
@@ -74,6 +74,9 @@
         App.config.setConfiguration(original_config)
         os.rmdir(TEMPPRODUCTS)
         os.rmdir(TEMPNAME)
+        import Products
+        Products.__path__ = [d for d in Products.__path__
+                             if os.path.exists(d)]
 
     def configure(self, text):
         # We have to create a directory of our own since the existence

Modified: Zope/trunk/lib/python/OFS/tests/testProductInit.py
===================================================================
--- Zope/trunk/lib/python/OFS/tests/testProductInit.py	2005-04-07 01:14:11 UTC (rev 29894)
+++ Zope/trunk/lib/python/OFS/tests/testProductInit.py	2005-04-07 03:49:30 UTC (rev 29895)
@@ -19,6 +19,7 @@
 import Zope2.Startup
 import ZConfig
 from App.config import getConfiguration, setConfiguration
+import Products
 
 TEMPNAME = tempfile.mktemp()
 TEMPPRODUCTS = os.path.join(TEMPNAME, "Products")
@@ -84,6 +85,8 @@
         del self.schema
         App.config.setConfiguration(original_config)
         shutil.rmtree(TEMPNAME)
+        Products.__path__ = [d for d in Products.__path__
+                             if os.path.exists(d)]
 
     def configure(self, text):
         # We have to create a directory of our own since the existence

Modified: Zope/trunk/lib/python/ThreadLock/tests.py
===================================================================
--- Zope/trunk/lib/python/ThreadLock/tests.py	2005-04-07 01:14:11 UTC (rev 29894)
+++ Zope/trunk/lib/python/ThreadLock/tests.py	2005-04-07 03:49:30 UTC (rev 29895)
@@ -57,7 +57,7 @@
 
 import ThreadLock, threading, time
 import unittest
-from doctest import DocTestSuite
+from zope.testing.doctest import DocTestSuite
 
 def test_suite():
     return unittest.TestSuite((

Copied: Zope/trunk/lib/python/ZClasses/27.fs (from rev 29894, Zope/branches/jim-fix-zclasses/lib/python/ZClasses/27.fs)


Property changes on: Zope/trunk/lib/python/ZClasses/27.fs
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Copied: Zope/trunk/lib/python/ZClasses/27.txt (from rev 29894, Zope/branches/jim-fix-zclasses/lib/python/ZClasses/27.txt)


Property changes on: Zope/trunk/lib/python/ZClasses/27.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: Zope/trunk/lib/python/ZClasses/Basic.py
===================================================================
--- Zope/trunk/lib/python/ZClasses/Basic.py	2005-04-07 01:14:11 UTC (rev 29894)
+++ Zope/trunk/lib/python/ZClasses/Basic.py	2005-04-07 03:49:30 UTC (rev 29895)
@@ -64,7 +64,7 @@
 
     def classIcon(self): return self.getClassAttr('icon','')
 
-    def show_class_id(self): return Globals.DatabaseVersion=='3'
+    def show_class_id(self): return True
 
     def class_id(self):
         return (self.getClassAttr('__module__','') or '')[1:]

Modified: Zope/trunk/lib/python/ZClasses/Property.py
===================================================================
--- Zope/trunk/lib/python/ZClasses/Property.py	2005-04-07 01:14:11 UTC (rev 29894)
+++ Zope/trunk/lib/python/ZClasses/Property.py	2005-04-07 03:49:30 UTC (rev 29895)
@@ -25,13 +25,13 @@
     def __setattr__(self, name, v):
         klass=self._k
         setattr(klass, name, v)
-        if not getattr(klass,'_p_changed',None):
+        if not getattr(klass,'_p_changed',None) and klass._p_jar is not None:
             transaction.get().register(klass)
             klass._p_changed=1
     def __delattr__(self, name):
         klass=self._k
         delattr(klass, name)
-        if not getattr(klass,'_p_changed',None):
+        if not getattr(klass,'_p_changed',None) and klass._p_jar is not None:
             transaction.get().register(klass)
             klass._p_changed=1
 
@@ -272,7 +272,7 @@
 Globals.default__class_init__(ZInstanceSheet)
 
 def rclass(klass):
-    if not getattr(klass, '_p_changed', 0):
+    if not getattr(klass, '_p_changed', 0) and klass._p_jar is not None:
         transaction.get().register(klass)
         klass._p_changed=1
 

Modified: Zope/trunk/lib/python/ZClasses/ZClass.py
===================================================================
--- Zope/trunk/lib/python/ZClasses/ZClass.py	2005-04-07 01:14:11 UTC (rev 29894)
+++ Zope/trunk/lib/python/ZClasses/ZClass.py	2005-04-07 03:49:30 UTC (rev 29895)
@@ -22,6 +22,7 @@
 from Products.PythonScripts.PythonScript import PythonScript
 from zExceptions import BadRequest, Redirect
 import webdav.Collection
+import ZClasses._pmc
 
 import transaction
 
@@ -93,8 +94,19 @@
 p_.ZClass_Icon=Globals.ImageFile('class.gif', globals())
 
 class PersistentClass(Base, webdav.Collection.Collection ):
-    def __class_init__(self): pass
 
+    __metaclass__ = ZClasses._pmc.ZClassPersistentMetaClass
+
+    # We need this class to be treated as a normal global class, even
+    # though it is an instance of ZClassPersistentMetaClass.
+    # Subclasses should be stored in the database.  See
+    # _pmc._p_DataDescr.__get__.
+    
+    __global_persistent_class_not_stored_in_DB__ = True
+    
+    def __class_init__(self):
+        pass
+
 manage_addZClassForm=Globals.DTMLFile(
     'dtml/addZClass', globals(),
     default_class_='OFS.SimpleItem Item',
@@ -116,12 +128,6 @@
             continue
         raise AttributeError, name
 
-def dbVersionEquals(ver):
-    # A helper function to isolate db version checking.
-    return hasattr(Globals, 'DatabaseVersion') and \
-       Globals.DatabaseVersion == ver
-
-
 bad_id=re.compile('[^a-zA-Z0-9_]').search
 
 def manage_addZClass(self, id, title='', baseclasses=[],
@@ -129,6 +135,7 @@
                      zope_object=0):
     """Add a Z Class
     """
+    
     if bad_id(id) is not None:
         raise BadRequest, (
             'The id %s is invalid as a class name.' % id)
@@ -337,8 +344,6 @@
 
     changeClassId__roles__ = ()  # Private
     def changeClassId(self, newid=None):
-        if not dbVersionEquals('3'):
-            return
         if newid is None: newid=self._new_class_id()
         self._unregister()
         if newid:
@@ -413,16 +418,12 @@
         self.propertysheets.methods.manage_afterClone(item)
 
     def manage_afterAdd(self, item, container):
-        if not dbVersionEquals('3'):
-            return
         if not self._zclass_.__module__:
             self.setClassAttr('__module__', self._new_class_id())
         self._register()
         self.propertysheets.methods.manage_afterAdd(item, container)
 
     def manage_beforeDelete(self, item, container):
-        if not dbVersionEquals('3'):
-            return
         self._unregister()
         self.propertysheets.methods.manage_beforeDelete(item, container)
 
@@ -517,7 +518,7 @@
     def setClassAttr(self, name, value):
         c=self._zclass_
         setattr(c, name, value)
-        if not c._p_changed:
+        if (not c._p_changed) and (c._p_jar is not None):
             transaction.get().register(c)
             c._p_changed=1
 
@@ -525,7 +526,7 @@
     def delClassAttr(self, name):
         c=self._zclass_
         delattr(c, name)
-        if not c._p_changed:
+        if (not c._p_changed) and (c._p_jar is not None):
             transaction.get().register(c)
             c._p_changed=1
 

Copied: Zope/trunk/lib/python/ZClasses/ZClass.txt (from rev 29894, Zope/branches/jim-fix-zclasses/lib/python/ZClasses/ZClass.txt)


Property changes on: Zope/trunk/lib/python/ZClasses/ZClass.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: Zope/trunk/lib/python/ZClasses/_pmc.py (from rev 29894, Zope/branches/jim-fix-zclasses/lib/python/ZClasses/_pmc.py)


Property changes on: Zope/trunk/lib/python/ZClasses/_pmc.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Copied: Zope/trunk/lib/python/ZClasses/_pmc.txt (from rev 29894, Zope/branches/jim-fix-zclasses/lib/python/ZClasses/_pmc.txt)


Property changes on: Zope/trunk/lib/python/ZClasses/_pmc.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: Zope/trunk/lib/python/ZClasses/tests.py (from rev 29894, Zope/branches/jim-fix-zclasses/lib/python/ZClasses/tests.py)
===================================================================
--- Zope/branches/jim-fix-zclasses/lib/python/ZClasses/tests.py	2005-04-07 01:14:11 UTC (rev 29894)
+++ Zope/trunk/lib/python/ZClasses/tests.py	2005-04-07 03:49:30 UTC (rev 29895)
@@ -0,0 +1,175 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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.
+#
+##############################################################################
+"""ZClass tests
+
+$Id$
+"""
+
+import os, sys
+import unittest
+import ZODB.tests.util
+import transaction
+from zope.testing import doctest
+
+
+# XXX need to update files to get newer testing package
+class FakeModule:
+    def __init__(self, name, dict):
+        self.__dict__ = dict
+        self.__name__ = name
+
+
+def setUp(test):
+    test.globs['some_database'] = ZODB.tests.util.DB()
+    module = FakeModule('ZClasses.example', test.globs)
+    sys.modules[module.__name__] = module
+
+def tearDown(test):
+    transaction.abort()
+    test.globs['some_database'].close()
+    del sys.modules['ZClasses.example']
+
+def tearDown27(test):
+    transaction.abort()
+    test.globs['db'].close()
+
+# XXX Two tests are disable because they're failing on Zope trunk;
+# XXX they didn't fail on Jim's branch:
+#
+# C:\Code\zt>\python23\python.exe test.py ZClas
+# Running unit tests from C:\Code\zt\lib\python
+# ======================================================================
+# FAIL: Doctest: ZClass.txt
+# ----------------------------------------------------------------------
+# Traceback (most recent call last):
+#   File "C:\Code\zt\lib\python\zope\testing\doctest.py", line 2102, in runTest
+#     raise self.failureException(self.format_failure(new.getvalue()))
+# AssertionError: Failed doctest test for ZClass.txt
+#   File "C:\Code\zt\lib\python\ZClasses\ZClass.txt", line 0
+#
+# ----------------------------------------------------------------------
+# File "C:\Code\zt\lib\python\ZClasses\ZClass.txt", line 88, in ZClass.txt
+# Failed example:
+#     print app2.c2.x, app2.c2.y, app2.c2.eek(), '!'
+# Exception raised:
+#     Traceback (most recent call last):
+#       File "C:\Code\zt\lib\python\zope\testing\doctest.py", line 1315, in __run
+#         compileflags, 1) in test.globs
+#       File "<doctest ZClass.txt[35]>", line 1, in ?
+#         print app2.c2.x, app2.c2.y, app2.c2.eek(), '!'
+#       File "C:\Code\zt\lib\python\AccessControl\PermissionMapping.py", line 150, in __call__
+#         return apply(self, args, kw)
+#       File "C:\Code\zt\lib\python\Shared\DC\Scripts\Bindings.py", line 311, in __call__
+#         return self._bindAndExec(args, kw, None)
+#       File "C:\Code\zt\lib\python\Shared\DC\Scripts\Bindings.py", line 348, in _bindAndExec
+#         return self._exec(bound_data, args, kw)
+#       File "C:\Code\zt\lib\python\Products\PythonScripts\PythonScript.py", line 323, in _exec
+#         result = f(*args, **kw)
+#       File "Script (Python)", line 1, in eek
+#     Unauthorized: You are not allowed to access 'x' in this context
+# ----------------------------------------------------------------------
+# File "C:\Code\zt\lib\python\ZClasses\ZClass.txt", line 110, in ZClass.txt
+# Failed example:
+#     c3.eek()
+# Exception raised:
+#     Traceback (most recent call last):
+#       File "C:\Code\zt\lib\python\zope\testing\doctest.py", line 1315, in __run
+#         compileflags, 1) in test.globs
+#       File "<doctest ZClass.txt[42]>", line 1, in ?
+#         c3.eek()
+#       File "C:\Code\zt\lib\python\AccessControl\PermissionMapping.py", line 150, in __call__
+#         return apply(self, args, kw)
+#       File "C:\Code\zt\lib\python\Shared\DC\Scripts\Bindings.py", line 311, in __call__
+#         return self._bindAndExec(args, kw, None)
+#       File "C:\Code\zt\lib\python\Shared\DC\Scripts\Bindings.py", line 348, in _bindAndExec
+#         return self._exec(bound_data, args, kw)
+#       File "C:\Code\zt\lib\python\Products\PythonScripts\PythonScript.py", line 323, in _exec
+#         result = f(*args, **kw)
+#       File "Script (Python)", line 1, in eek
+#     Unauthorized: You are not allowed to access 'x' in this context
+#
+#
+# ======================================================================
+# FAIL: Doctest: 27.txt
+# ----------------------------------------------------------------------
+# Traceback (most recent call last):
+#   File "C:\Code\zt\lib\python\zope\testing\doctest.py", line 2102, in runTest
+#     raise self.failureException(self.format_failure(new.getvalue()))
+# AssertionError: Failed doctest test for 27.txt
+#   File "C:\Code\zt\lib\python\ZClasses\27.txt", line 0
+#
+# ----------------------------------------------------------------------
+# File "C:\Code\zt\lib\python\ZClasses\27.txt", line 16, in 27.txt
+# Failed example:
+#     ac.eek()
+# Exception raised:
+#     Traceback (most recent call last):
+#       File "C:\Code\zt\lib\python\zope\testing\doctest.py", line 1315, in __run
+#         compileflags, 1) in test.globs
+#       File "<doctest 27.txt[10]>", line 1, in ?
+#         ac.eek()
+#       File "C:\Code\zt\lib\python\AccessControl\PermissionMapping.py", line 150, in __call__
+#         return apply(self, args, kw)
+#       File "C:\Code\zt\lib\python\Shared\DC\Scripts\Bindings.py", line 311, in __call__
+#         return self._bindAndExec(args, kw, None)
+#       File "C:\Code\zt\lib\python\Shared\DC\Scripts\Bindings.py", line 348, in _bindAndExec
+#         return self._exec(bound_data, args, kw)
+#       File "C:\Code\zt\lib\python\Products\PythonScripts\PythonScript.py", line 323, in _exec
+#         result = f(*args, **kw)
+#       File "Script (Python)", line 1, in eek
+#     Unauthorized: You are not allowed to access 'x' in this context
+# ----------------------------------------------------------------------
+# File "C:\Code\zt\lib\python\ZClasses\27.txt", line 19, in 27.txt
+# Failed example:
+#     ac.eek()
+# Exception raised:
+#     Traceback (most recent call last):
+#       File "C:\Code\zt\lib\python\zope\testing\doctest.py", line 1315, in __run
+#         compileflags, 1) in test.globs
+#       File "<doctest 27.txt[12]>", line 1, in ?
+#         ac.eek()
+#       File "C:\Code\zt\lib\python\AccessControl\PermissionMapping.py", line 150, in __call__
+#         return apply(self, args, kw)
+#       File "C:\Code\zt\lib\python\Shared\DC\Scripts\Bindings.py", line 311, in __call__
+#         return self._bindAndExec(args, kw, None)
+#       File "C:\Code\zt\lib\python\Shared\DC\Scripts\Bindings.py", line 348, in _bindAndExec
+#         return self._exec(bound_data, args, kw)
+#       File "C:\Code\zt\lib\python\Products\PythonScripts\PythonScript.py", line 323, in _exec
+#         result = f(*args, **kw)
+#       File "Script (Python)", line 1, in eek
+#     Unauthorized: You are not allowed to access 'x' in this context
+#
+#
+# ----------------------------------------------------------------------
+# Ran 3 tests in 2.734s
+#
+# FAILED (failures=2)
+
+def test_suite():
+    return unittest.TestSuite((
+
+        # To do:
+        # - Test working with old pickles
+        # - Test proper handling of __of__
+        # - Test export/import
+
+        doctest.DocFileSuite("_pmc.txt", setUp=setUp, tearDown=tearDown),
+        ## XXX doctest.DocFileSuite("ZClass.txt", setUp=setUp, tearDown=tearDown),
+        ## XXX doctest.DocFileSuite("27.txt", tearDown=tearDown27,
+        ## XXX                    globs=dict(__file__=__file__),
+        ## XXX                     ),
+        ))
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')


Property changes on: Zope/trunk/lib/python/ZClasses/tests.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: Zope/trunk/lib/python/ZPublisher/tests/testPublish.py
===================================================================
--- Zope/trunk/lib/python/ZPublisher/tests/testPublish.py	2005-04-07 01:14:11 UTC (rev 29894)
+++ Zope/trunk/lib/python/ZPublisher/tests/testPublish.py	2005-04-07 03:49:30 UTC (rev 29895)
@@ -267,7 +267,7 @@
     pass
 
 
-import doctest
+from zope.testing import doctest
 
 def test_suite():
     return doctest.DocTestSuite()

Modified: Zope/trunk/lib/python/Zope2/App/startup.py
===================================================================
--- Zope/trunk/lib/python/Zope2/App/startup.py	2005-04-07 01:14:11 UTC (rev 29894)
+++ Zope/trunk/lib/python/Zope2/App/startup.py	2005-04-07 03:49:30 UTC (rev 29895)
@@ -40,8 +40,6 @@
 def startup():
     global app
 
-    Globals.DatabaseVersion='3'
-
     # Import products
     OFS.Application.import_products()
 



More information about the Zope-Checkins mailing list