[Zope-CVS] CVS: Products/Ape/lib/apelib/config - apeconf.py:1.7 common.py:1.4 interfaces.py:1.3

Shane Hathaway shane at zope.com
Sat Mar 20 01:34:52 EST 2004


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

Modified Files:
	apeconf.py common.py interfaces.py 
Log Message:
Converted method and function names to conform with PEP 8.

PEP 8 (or perhaps the next revision) recommends 
lowercase_with_underscores over mixedCase.  Since everything is being 
renamed for this release anyway, why not throw in this too? :-)

Also got SQLMultiTableProperties back into shape.



=== Products/Ape/lib/apelib/config/apeconf.py 1.6 => 1.7 ===
--- Products/Ape/lib/apelib/config/apeconf.py:1.6	Sat Mar 13 17:22:53 2004
+++ Products/Ape/lib/apelib/config/apeconf.py	Sat Mar 20 01:34:21 2004
@@ -29,46 +29,46 @@
 
 class MapperDeclaration(Directive):
     schema = TableSchema()
-    schema.addColumn('mapper_name', primary=1)
+    schema.add('mapper_name', primary=1)
 
 
 class MapperAttribute(Directive):
     schema = TableSchema()
-    schema.addColumn('mapper_name', primary=1)
+    schema.add('mapper_name', primary=1)
     # Attribute names: 'class', 'extends', 'register-class'
-    schema.addColumn('name', primary=1, indexed=1)
-    schema.addColumn('value')
+    schema.add('name', primary=1, indexed=1)
+    schema.add('value')
 
 
 class ComponentDefinition(Directive):
     schema = TableSchema()
     # comptypes: 'serializer', 'gateway', 'classifier', 'oid_generator'
-    schema.addColumn('comptype', primary=1)
-    schema.addColumn('name', primary=1)
-    schema.addColumn('producer')
+    schema.add('comptype', primary=1)
+    schema.add('name', primary=1)
+    schema.add('producer')
 
 
 class MapperComponent(Directive):
     schema = TableSchema()
-    schema.addColumn('mapper_name', primary=1)
-    schema.addColumn('comptype', primary=1)
-    schema.addColumn('name', primary=1)
-    schema.addColumn('producer')
-    schema.addColumn('order')
+    schema.add('mapper_name', primary=1)
+    schema.add('comptype', primary=1)
+    schema.add('name', primary=1)
+    schema.add('producer')
+    schema.add('order')
 
 
 class MapperUseFor(Directive):
     schema = TableSchema()
-    schema.addColumn('mapper_name', primary=1)
-    schema.addColumn('attr', primary=1)
-    schema.addColumn('value', primary=1)  # Multiple values allowed
+    schema.add('mapper_name', primary=1)
+    schema.add('attr', primary=1)
+    schema.add('value', primary=1)  # Multiple values allowed
 
 
 class ClassifierOption(Directive):
     schema = TableSchema()
-    schema.addColumn('mapper_name', primary=1)
-    schema.addColumn('option', primary=1)
-    schema.addColumn('value')
+    schema.add('mapper_name', primary=1)
+    schema.add('option', primary=1)
+    schema.add('value')
 
 
 class DisabledProducer:
@@ -126,7 +126,7 @@
         return c(*params)
 
 
-def makeProducer(source, comptype, attrs, raise_exc=1):
+def make_producer(source, comptype, attrs, raise_exc=1):
     if attrs.get('enabled', '').lower() == 'false':
         return DisabledProducer(source)
     elif attrs.has_key('use'):
@@ -141,7 +141,7 @@
         return None
 
 
-def getElementHandlers():
+def get_element_handlers():
     """Returns a dictionary of XML element handlers.
     """
 
@@ -177,7 +177,7 @@
 
     def handle_mapper_component(source, vars, attrs, comptype):
         d = vars['directives']
-        producer = makeProducer(source, comptype, attrs)
+        producer = make_producer(source, comptype, attrs)
         mapper_name = vars.get('mapper_name')
         if mapper_name is None:
             # Reusable component
@@ -208,20 +208,20 @@
                 raise ValueError(
                     "Multiple gateways in classifiers not allowed at %s" %
                     source)
-            p.sub_producer = makeProducer(source, 'gateway', attrs)
+            p.sub_producer = make_producer(source, 'gateway', attrs)
         else:
             handle_mapper_component(source, vars, attrs, 'gateway')
 
     def handle_classifier(source, vars, attrs):
         d = vars['directives']
-        producer = makeProducer(source, 'classifier', attrs)
+        producer = make_producer(source, 'classifier', attrs)
         directive = ComponentDefinition(source, 'classifier', '', producer)
         d.append(directive)
         vars['classifier_producer'] = producer
 
     def handle_oid_generator(source, vars, attrs):
         d = vars['directives']
-        producer = makeProducer(source, 'oid_generator', attrs)
+        producer = make_producer(source, 'oid_generator', attrs)
         directive = ComponentDefinition(source, 'oid_generator', '', producer)
         d.append(directive)
 
@@ -309,9 +309,9 @@
         self.attrs = {}
         for record in dtables.query(MapperAttribute, mapper_name=name):
             self.attrs[record.name] = record.value
-        self.prepareSubComponents()
+        self._prepare_sub_components()
 
-    def prepareSubComponents(self):
+    def _prepare_sub_components(self):
         self.multi_comps = {}  # comptype -> name -> record
         dtables = self.compsys.dtables
         name = self.mapper_name
@@ -323,7 +323,7 @@
             for r in records:
                 d = self.multi_comps.setdefault(r.comptype, {})
                 d.setdefault(r.name, r)
-            name = dtables.queryField(
+            name = dtables.query_field(
                 MapperAttribute, 'value', mapper_name=name, name='extends')
             if name and name in all_names:
                 raise ConfigurationError(
@@ -334,11 +334,11 @@
         return self.obj
 
     def configure(self):
-        self.addSerializers()
-        self.addGateways()
-        self.addInitializers()
+        self.add_serializers()
+        self.add_gateways()
+        self.add_initializers()
 
-    def addSerializers(self):
+    def add_serializers(self):
         cname = self.attrs.get('class')
         if cname == 'none':
             # This mapper is abstract (usable for no classes)
@@ -374,7 +374,7 @@
         # Assign it
         self.obj.serializer = s
 
-    def addGateways(self):
+    def add_gateways(self):
         d = self.multi_comps.get('gateway', {})
 
         # Create the main gateway
@@ -395,7 +395,7 @@
         # Assign it
         self.obj.gateway = g
 
-    def addInitializers(self):
+    def add_initializers(self):
         for o in self.subobjs:
             if IDatabaseInitializer.isImplementedBy(o):
                 self.obj.initializers.append(o)
@@ -433,12 +433,12 @@
                         repr(r.attr), repr(r.value)))
                 all_regs[key] = name
 
-            register_class = dtables.queryField(
+            register_class = dtables.query_field(
                 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(
+                class_name = dtables.query_field(
                     MapperAttribute, 'value', mapper_name=name, name='class')
                 if class_name is None:
                     class_name = name
@@ -464,23 +464,23 @@
             for (attr, value), name in all_regs.items():
                 self.obj.register(attr, value, name)
             for (name, option), value in all_options.items():
-                self.obj.setOption(name, option, value)
+                self.obj.set_option(name, option, value)
             
         
 
 def configure(filenames, vname=''):
     """Returns a MapperConfiguration built from configuration files.
     """
-    handlers = getElementHandlers()
+    handlers = get_element_handlers()
     reader = DirectiveReader(handlers)
     for fn in filenames:
         reader.read(fn)
-    directives = reader.getDirectives(vname)
+    directives = reader.get_directives(vname)
     cs = ComponentSystem(directives)
-    cs.addComponentType('mapper', MapperAssembler)
-    cs.addComponentType('classifier', ClassifierAssembler)
+    cs.add_component_type('mapper', MapperAssembler)
+    cs.add_component_type('classifier', ClassifierAssembler)
     for comptype in ('serializer', 'gateway', 'oid_generator'):
-        cs.addComponentType(comptype, BasicComponentAssembler)
+        cs.add_component_type(comptype, BasicComponentAssembler)
     mappers = {}
     for record in cs.dtables.query(MapperDeclaration):
         name = record.mapper_name


=== Products/Ape/lib/apelib/config/common.py 1.3 => 1.4 ===
--- Products/Ape/lib/apelib/config/common.py:1.3	Mon Feb  2 10:07:17 2004
+++ Products/Ape/lib/apelib/config/common.py	Sat Mar 20 01:34:21 2004
@@ -31,7 +31,7 @@
     def __init__(self, source, *args, **kw):
         self.source = source
         if args:
-            columns = self.schema.getColumns()
+            columns = self.schema.get_columns()
             for n in range(len(args)):
                 key = columns[n].name
                 if kw.has_key(key):
@@ -46,7 +46,7 @@
                 unique_key.append(kw[column.name])
         self.unique_key = tuple(unique_key)
 
-    def getUniqueKey(self):
+    def get_unique_key(self):
         return self.unique_key
 
     def index(self, tables):
@@ -116,7 +116,7 @@
 
     def add(self, directives, vname):
         for d in directives:
-            key = d.getUniqueKey()
+            key = d.get_unique_key()
             info = self.directives.setdefault(key, {})
             if info.has_key(vname):
                 if d == info[vname]:
@@ -129,7 +129,7 @@
             else:
                 info[vname] = d
 
-    def getDirectives(self, vname=''):
+    def get_directives(self, vname=''):
         res = []
         # Note that although there isn't a way to declare that a
         # variation extends another variation, all variations should
@@ -163,7 +163,7 @@
             return []
         return t.select(filter)
 
-    def queryField(self, table_name, field, **filter):
+    def query_field(self, table_name, field, **filter):
         t = self.tables.get(table_name)
         if t is None:
             return None
@@ -183,7 +183,7 @@
         self.factories = {}   # {comptype -> assembler factory}
         self.components = {}  # {(comptype, name) -> component}
 
-    def addComponentType(self, comptype, assembler_factory):
+    def add_component_type(self, comptype, assembler_factory):
         self.factories[comptype] = assembler_factory
 
     def get(self, comptype, name):


=== Products/Ape/lib/apelib/config/interfaces.py 1.2 => 1.3 ===
--- Products/Ape/lib/apelib/config/interfaces.py:1.2	Wed Jul  9 11:39:55 2003
+++ Products/Ape/lib/apelib/config/interfaces.py	Sat Mar 20 01:34:21 2004
@@ -22,7 +22,7 @@
     """A configuration directive.
     """
 
-    def getUniqueKey():
+    def get_unique_key():
         """Returns a key that distinguishes this directive from all others.
 
         This is used to detect conflicting directives.  The result




More information about the Zope-CVS mailing list