[Zope-CVS] CVS: Products/Ape/lib/apelib/config - apeconf.py:1.4.2.2

Shane Hathaway shane at zope.com
Sat Dec 20 23:24:34 EST 2003


Update of /cvs-repository/Products/Ape/lib/apelib/config
In directory cvs.zope.org:/tmp/cvs-serv18412/lib/apelib/config

Modified Files:
      Tag: ape-0_8-branch
	apeconf.py 
Log Message:
Continued cleanup after refactoring the interfaces.  See CHANGES.txt.

All tests now pass except for the SQL tests.



=== Products/Ape/lib/apelib/config/apeconf.py 1.4.2.1 => 1.4.2.2 ===
--- Products/Ape/lib/apelib/config/apeconf.py:1.4.2.1	Sat Dec 20 02:31:02 2003
+++ Products/Ape/lib/apelib/config/apeconf.py	Sat Dec 20 23:24:02 2003
@@ -17,11 +17,10 @@
 """
 from __future__ import nested_scopes
 
-from apelib.core.mapper import Mapper
+from apelib.core.mapper import Mapper, MapperConfiguration
 from apelib.core.serializers import CompositeSerializer, AnyObjectSerializer
 from apelib.core.gateways import CompositeGateway
 from apelib.core.interfaces import IDatabaseInitializer, ConfigurationError
-from apelib.core.io import MapperConfiguration
 
 from minitables import Table, TableSchema
 from common import Directive, DirectiveReader, ComponentSystem
@@ -35,7 +34,7 @@
 class MapperAttribute(Directive):
     schema = TableSchema()
     schema.addColumn('mapper_name', primary=1)
-    # Attribute names: 'class', 'parent', 'extends'
+    # Attribute names: 'class', 'extends', 'register-class'
     schema.addColumn('name', primary=1, indexed=1)
     schema.addColumn('value')
 
@@ -154,9 +153,17 @@
         mapper_name = str(attrs['name'])
         vars['mapper_name'] = mapper_name
         d.append(MapperDeclaration(source, mapper_name))
-        for key in ('class', 'parent', 'extends'):
+        for key in ('class', 'extends', 'register-class'):
             if attrs.has_key(key):
-                d.append(MapperAttribute(source, mapper_name, key, attrs[key]))
+                value = attrs[key]
+                if (key == 'register'):
+                    if value.lower() == 'true':
+                        value = True
+                    elif value.lower == 'false':
+                        value = False
+                    else:
+                        raise ValueError("Value must be true or false")
+                d.append(MapperAttribute(source, mapper_name, key, value))
 
     def handle_mapper_component(source, vars, attrs, comptype):
         d = vars['directives']
@@ -211,7 +218,7 @@
     def handle_use_for(source, vars, attrs):
         d = vars['directives']
         mapper_name = vars['mapper_name']
-        for attr in ('class', 'extensions', 'generic'):
+        for attr in ('class', 'extensions', 'generic', 'oid'):
             if attrs.has_key(attr):
                 v = attrs[attr]
                 if attr == 'extensions':
@@ -311,11 +318,6 @@
             if name and name in all_names:
                 raise ConfigurationError(
                     "Circular extension in mappers %s" % repr(all_names))
-        self.sub_mapper_names = []
-        records = dtables.query(
-            MapperAttribute, name='parent', value=self.mapper_name)
-        for r in records:
-            self.sub_mapper_names.append(r['mapper_name'])
 
     def create(self):
         self.obj = Mapper()
@@ -342,7 +344,7 @@
             if pos < 0:
                 raise ConfigurationError("Class name must include a module name")
             s = CompositeSerializer(cname[:pos], cname[pos + 1:])
-        
+
         d = self.multi_comps.get('serializer')
         if d:
             ordered = [(r.get('order', '').lower(), name, r)
@@ -404,22 +406,25 @@
                         repr(r['attr']), repr(r['value'])))
                 all_regs[key] = name
 
-            # class="" attributes
-            class_name = dtables.queryField(
-                MapperAttribute, 'value', mapper_name=name, name='class')
-            if class_name is None:
-                class_name = name
-            elif class_name in ('none', 'any'):
-                class_name = None
-            if class_name is not None:
-                # Translate into an implicit use-for directive
-                key = ('class', class_name)
-                if all_regs.has_key(key) and all_regs[key] != name:
-                    raise ConfigurationError(
-                        "Mappers %s and %s are contending over %s == %s" % (
-                        name, all_regs[key],
-                        "'class'", repr(class_name)))
-                all_regs[key] = name
+            register_class = dtables.queryField(
+                MapperAttribute, 'value', mapper_name=name,
+                name='register-class')
+            if register_class or register_class is None:
+                # Create an implicit 'use-for class' directive
+                class_name = dtables.queryField(
+                    MapperAttribute, 'value', mapper_name=name, name='class')
+                if class_name is None:
+                    class_name = name
+                elif class_name in ('none', 'any'):
+                    class_name = None
+                if class_name is not None:
+                    key = ('class', class_name)
+                    if all_regs.has_key(key) and all_regs[key] != name:
+                        raise ConfigurationError(
+                            "Mappers %s and %s are contending over %s == %s" % (
+                            name, all_regs[key],
+                            "'class'", repr(class_name)))
+                    all_regs[key] = name
 
             # options
             records = dtables.query(




More information about the Zope-CVS mailing list