[Zope3-checkins] CVS: Zope3/src/zope/app/schemagen - modulegen.py:1.3 schemaspec.py:1.3 typereg.py:1.4

Steve Alexander steve@cat-box.net
Wed, 4 Jun 2003 06:47:08 -0400


Update of /cvs-repository/Zope3/src/zope/app/schemagen
In directory cvs.zope.org:/tmp/cvs-serv10932/src/zope/app/schemagen

Modified Files:
	modulegen.py schemaspec.py typereg.py 
Log Message:
new style implements().
This caused other changes to schemagen.


=== Zope3/src/zope/app/schemagen/modulegen.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/schemagen/modulegen.py:1.2	Wed Dec 25 09:13:14 2002
+++ Zope3/src/zope/app/schemagen/modulegen.py	Wed Jun  4 06:46:37 2003
@@ -46,7 +46,7 @@
     property_text = '\n'.join(property_text_list)
 
     text = '''\
-from zope.interface import Interface
+from zope.interface import Interface, implements
 from persistence import Persistent
 from zope.schema.fieldproperty import FieldProperty
 
@@ -59,7 +59,7 @@
 
 class %(class_name)s(Persistent):
     """Autogenerated class for %(schema_name)s."""
-    __implements__ = %(schema_name)s
+    implements(%(schema_name)s)
 
     def __init__(self):
         self.__schema_version__ = %(schema_version)s


=== Zope3/src/zope/app/schemagen/schemaspec.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/schemagen/schemaspec.py:1.2	Wed Dec 25 09:13:14 2002
+++ Zope3/src/zope/app/schemagen/schemaspec.py	Wed Jun  4 06:46:37 2003
@@ -19,12 +19,13 @@
 from zope.app.interfaces.schemagen import ISchemaSpec
 from persistence import Persistent
 from zope.app.schemagen.modulegen import generateModuleSource
+from zope.interface import implements
 
 _helper_import = 'from zope.app.schemagen import schemaspec'
 _helper_module = 'schemaspec'
 
 class SchemaSpec(Persistent):
-    __implements__ = ISchemaSpec
+    implements(ISchemaSpec)
 
     def __init__(self, schema_name, class_name=None):
         if class_name is None:


=== Zope3/src/zope/app/schemagen/typereg.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/schemagen/typereg.py:1.3	Wed Jan  8 15:18:29 2003
+++ Zope3/src/zope/app/schemagen/typereg.py	Wed Jun  4 06:46:37 2003
@@ -18,7 +18,7 @@
 $Id$
 """
 
-from zope.interface.implements import visitImplements
+from zope.interface import implements, providedBy
 from zope.schema import getFields
 
 from zope.app.interfaces.schemagen import ITypeRepresentation
@@ -43,7 +43,7 @@
             self._registry[type] = representation
 
 class DefaultTypeRepresentation:
-    __implements__ = ITypeRepresentation
+    implements(ITypeRepresentation)
 
     def __init__(self, object):
         self.text = repr(object)
@@ -59,7 +59,7 @@
     getTypes = staticmethod(getTypes)
 
 class DatetimeRepresentation:
-    __implements__ = ITypeRepresentation
+    implements(ITypeRepresentation)
 
     def __init__(self, dt):
         r = repr(dt)
@@ -79,18 +79,18 @@
     getTypes = staticmethod(getTypes)
 
 class DefaultFieldRepresentation:
-    __implements__ = ITypeRepresentation
+    implements(ITypeRepresentation)
 
     def __init__(self, field):
-        # This field is described by a schema, or schemas, as found in its
-        # __implements__ attribute. The fields of this field's schema are
+        # This field is described by a schema, or schemas, as found by
+        # providedBy. The fields of this field's schema are
         # its properties -- that is, the things we give as arguments when
         # constructing this field.
         # We're going to get these properties, get source-code
         # representations of them, and sort out appropriate imports.
         names = {} # used as set of property names, ignoring values
-        visitImplements(field.__implements__, field,
-                        lambda interface: names.update(getFields(interface)))
+        for interface in providedBy(field):
+            names.update(getFields(interface))
         # getFields only returns data for Fields in the interface.
         # Otherwise, it returns an empty dict.