[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/schemagen - schemaspec.py:1.2

Martijn Faassen m.faassen@vet.uu.nl
Thu, 12 Dec 2002 13:28:04 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/schemagen
In directory cvs.zope.org:/tmp/cvs-serv17059

Modified Files:
	schemaspec.py 
Log Message:
Added some tests for various forms of source code generations. Also
made generateModuleSource on schemaspec.SchemaSpec not generate
__setstate__ method to upgrade history when this isn't necessary.


=== Zope3/lib/python/Zope/App/schemagen/schemaspec.py 1.1 => 1.2 ===
--- Zope3/lib/python/Zope/App/schemagen/schemaspec.py:1.1	Thu Dec 12 12:43:15 2002
+++ Zope3/lib/python/Zope/App/schemagen/schemaspec.py	Thu Dec 12 13:28:03 2002
@@ -138,12 +138,19 @@
         return '\n'.join(method_text_list) + '\n'
     
     def generateModuleSource(self):
-        return generateModuleSource(
-            self._schema_name, self.getFieldsInOrder(),
-            self._class_name,
-            schema_version=self._current_version,
-            extra_imports=_helper_import,
-            extra_methods=self.generateSetstateSource())
+        if not self._history:
+            # don't generate any __setstate__ when there is no history
+            # to update from
+            return generateModuleSource(
+                self._schema_name, self.getFieldsInOrder(),
+                self._class_name, schema_version=self._current_version)
+        else:
+            return generateModuleSource(
+                self._schema_name, self.getFieldsInOrder(),
+                self._class_name,
+                schema_version=self._current_version,
+                extra_imports=_helper_import,
+                extra_methods=self.generateSetstateSource())
 
 # future plans, perhaps:
 # make each of these classes have views, and a method that