[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/schemacontent/ Schemas are now copied before they are appended to content type or

Stephan Richter srichter at cosmos.phy.tufts.edu
Thu Jul 8 18:38:18 EDT 2004


Log message for revision 26261:
Schemas are now copied before they are appended to content type or
instance. This should probably become a policy later.



-=-
Modified: Zope3/trunk/src/zope/app/schemacontent/content.py
===================================================================
--- Zope3/trunk/src/zope/app/schemacontent/content.py	2004-07-08 22:36:47 UTC (rev 26260)
+++ Zope3/trunk/src/zope/app/schemacontent/content.py	2004-07-08 22:38:18 UTC (rev 26261)
@@ -291,9 +291,8 @@
         # Save the name of the object
         self.__name__ = name
 
-        # XXX: We really should make a copy of the schema first, so that it
-        #      cannot be changed.
-        self.__schema = schema
+        self.__schema = object.__new__(schema.__class__)
+        self.__schema.__dict__.update(schema.__dict__)
         # Add the new attributes, if there was a schema passed in
         if schema is not None:
             for name, field in getFields(schema).items():

Modified: Zope3/trunk/src/zope/app/schemacontent/instance.py
===================================================================
--- Zope3/trunk/src/zope/app/schemacontent/instance.py	2004-07-08 22:36:47 UTC (rev 26260)
+++ Zope3/trunk/src/zope/app/schemacontent/instance.py	2004-07-08 22:38:18 UTC (rev 26261)
@@ -47,9 +47,8 @@
         # Save the name of the object
         self.__name__ = name
 
-        # XXX: We really should make a copy of the schema first, so that it
-        #      cannot be changed.
-        self.__schema = schema
+        self.__schema = object.__new__(schema.__class__)
+        self.__schema.__dict__.update(schema.__dict__)
         # Add the new attributes, if there was a schema passed in
         if schema is not None:
             for name, field in getFields(schema).items():

Modified: Zope3/trunk/src/zope/app/schemacontent/tests/test_content.py
===================================================================
--- Zope3/trunk/src/zope/app/schemacontent/tests/test_content.py	2004-07-08 22:36:47 UTC (rev 26260)
+++ Zope3/trunk/src/zope/app/schemacontent/tests/test_content.py	2004-07-08 22:38:18 UTC (rev 26261)
@@ -217,7 +217,8 @@
         
     def test_getSchema(self):
         doc = ContentComponentInstance('Document', IDocument)
-        self.assertEqual(doc.getSchema(), IDocument)
+        self.assertEqual(doc.getSchema().__class__, IDocument.__class__)
+        self.assertEqual(doc.getSchema().__dict__, IDocument.__dict__)
 
 def test_suite():
     return unittest.TestSuite((



More information about the Zope3-Checkins mailing list