[Zope-CVS] CVS: Products/Ape/lib/apelib/zope2 - apeconf.xml:1.10
classifier.py:1.9 mapper.py:1.4 ofsserial.py:1.10
scripts.py:1.5 security.py:1.6
Shane Hathaway
shane at zope.com
Sat Mar 20 01:34:56 EST 2004
Update of /cvs-repository/Products/Ape/lib/apelib/zope2
In directory cvs.zope.org:/tmp/cvs-serv19743/lib/apelib/zope2
Modified Files:
apeconf.xml classifier.py mapper.py ofsserial.py scripts.py
security.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/zope2/apeconf.xml 1.9 => 1.10 ===
--- Products/Ape/lib/apelib/zope2/apeconf.xml:1.9 Wed Mar 17 10:55:52 2004
+++ Products/Ape/lib/apelib/zope2/apeconf.xml Sat Mar 20 01:34:25 2004
@@ -97,6 +97,12 @@
<gateway name="properties"
factory="apelib.sql.properties.SQLProperties" />
</variation>
+ <variation name="sql-fixed">
+ <!-- Note: there is currently no good way to use of directives in
+ special variations. Ape needs a way to make use of them. -->
+ <gateway name="properties"
+ factory="apelib.sql.properties.SQLMultiTableProperties" />
+ </variation>
</mapper>
<!-- 'common_text' is an abstract mapper with properties and a text body -->
=== Products/Ape/lib/apelib/zope2/classifier.py 1.8 => 1.9 ===
--- Products/Ape/lib/apelib/zope2/classifier.py:1.8 Sat Feb 28 15:06:29 2004
+++ Products/Ape/lib/apelib/zope2/classifier.py Sat Mar 20 01:34:25 2004
@@ -71,12 +71,12 @@
raise ValueError('Unknown classification condition: %s'
% repr(condition))
- def setOption(self, mapper_name, option, value):
+ def set_option(self, mapper_name, option, value):
assert option in ('default_extension', 'content_type_attr'), option
self.options[(mapper_name, option)] = value
- def classifyObject(self, event):
+ def classify_object(self, event):
"""Chooses a mapper and classification for storing an object.
"""
mapper_name = self.oid_to_mapper.get(event.oid)
@@ -112,7 +112,7 @@
return classification
- def classifyState(self, event):
+ def classify_state(self, event):
"""Chooses a mapper and classification for loading an object.
"""
mapper_name = self.oid_to_mapper.get(event.oid)
=== Products/Ape/lib/apelib/zope2/mapper.py 1.3 => 1.4 ===
--- Products/Ape/lib/apelib/zope2/mapper.py:1.3 Mon Feb 2 10:07:23 2004
+++ Products/Ape/lib/apelib/zope2/mapper.py Sat Mar 20 01:34:25 2004
@@ -21,7 +21,7 @@
from apelib.config.apeconf import configure
-def loadConf(vname, search_products=0):
+def load_conf(vname, search_products=0):
"""Builds a mapper from apeconf.xml files.
"""
here = os.path.dirname(__file__)
@@ -38,29 +38,29 @@
return configure(filenames, vname)
-def createFSMapper(basepath, **kw):
+def create_fs_mapper(basepath, **kw):
"""Filesystem mapper factory.
Returns (mapper, { name -> connection })
Usage in database configuration file:
- factory=apelib.zope2.mapper.createFSMapper
+ factory=apelib.zope2.mapper.create_fs_mapper
basepath=/var/zope/data
"""
from apelib.fs.connection import FSConnection
- mapper = loadConf('filesystem', search_products=1)
+ mapper = load_conf('filesystem', search_products=1)
conn = FSConnection(basepath, **kw)
return mapper, {'fs': conn}
-def createSQLMapper(module_name, **kw):
+def create_sql_mapper(module_name, **kw):
"""SQL mapper factory.
Returns (mapper, { name -> connection })
Usage in database configuration file:
- factory=apelib.zope2.mapper.createSQLMapper
+ factory=apelib.zope2.mapper.create_sql_mapper
module_name=psycopg
params=
kwparams=
@@ -68,7 +68,7 @@
"""
from apelib.sql.dbapi import DBAPIConnector
- mapper = loadConf('sql', search_products=1)
+ mapper = load_conf('sql', search_products=1)
conn = DBAPIConnector(module_name, **kw)
return mapper, {'db': conn}
=== Products/Ape/lib/apelib/zope2/ofsserial.py 1.9 => 1.10 ===
--- Products/Ape/lib/apelib/zope2/ofsserial.py:1.9 Tue Mar 16 23:02:59 2004
+++ Products/Ape/lib/apelib/zope2/ofsserial.py Sat Mar 20 01:34:25 2004
@@ -28,7 +28,7 @@
from apelib.core.interfaces import ISerializer, SerializationError
from apelib.core.schemas import FieldSchema, RowSequenceSchema
from apelib.core.serializers import OptionalSerializer
-from apelib.zodb3.serializers import findUnmanaged
+from apelib.zodb3.serializers import find_unmanaged
string_repr_types = {
@@ -52,7 +52,7 @@
schema = FieldSchema('data', 'string')
- def canSerialize(self, object):
+ def can_serialize(self, object):
return isinstance(object, File)
def serialize(self, event):
@@ -81,14 +81,14 @@
__implements__ = ISerializer
schema = RowSequenceSchema()
- schema.addField('key', 'string', 1)
- schema.addField('oid', 'string')
- schema.addField('classification', 'classification')
+ schema.add('key', 'string', 1)
+ schema.add('oid', 'string')
+ schema.add('classification', 'classification')
- def canSerialize(self, obj):
+ def can_serialize(self, obj):
return isinstance(obj, ObjectManager)
- def _isABTreeFolder(self, ob):
+ def _is_a_btree_folder(self, ob):
# Maybe this should use isinstance(), but then Ape
# would depend on the BTreeFolder2 product.
return hasattr(ob, '_tree') and hasattr(ob, '_mt_index')
@@ -99,7 +99,7 @@
state = []
event.ignore('_objects')
d = obj.__dict__
- btree_folder = self._isABTreeFolder(obj)
+ btree_folder = self._is_a_btree_folder(obj)
if btree_folder:
d = obj._tree
event.ignore(('_tree', '_mt_index', '_count'))
@@ -118,13 +118,13 @@
if btree_folder:
# The structure that makes up the BTree (the root node and
# the buckets) are unmanaged. Tell the event about them.
- event.upos.extend(findUnmanaged(obj._tree, obj._tree.values()))
+ event.upos.extend(find_unmanaged(obj._tree, obj._tree.values()))
return state
def deserialize(self, event, state):
obj = event.obj
assert isinstance(obj, ObjectManager), obj
- btree_folder = self._isABTreeFolder(obj)
+ btree_folder = self._is_a_btree_folder(obj)
if btree_folder:
obj._initBTrees()
for (id, oid, classification) in state:
@@ -137,7 +137,7 @@
},)
if btree_folder:
# The tree and the buckets are unmanaged.
- event.upos.extend(findUnmanaged(obj._tree, obj._tree.values()))
+ event.upos.extend(find_unmanaged(obj._tree, obj._tree.values()))
class IdAttribute:
@@ -147,10 +147,10 @@
schema = FieldSchema('id', 'string')
- def canSerialize(self, obj):
+ def can_serialize(self, obj):
return 1
- def getAttrNameFor(self, obj):
+ def _get_attr_name_for(self, obj):
if isinstance(obj, Item_w__name__):
return '__name__'
else:
@@ -158,7 +158,7 @@
def serialize(self, event):
obj = event.obj
- attrname = self.getAttrNameFor(obj)
+ attrname = self._get_attr_name_for(obj)
id = getattr(obj, attrname)
if not id:
raise SerializationError('ID of %r is %r' % (obj, id))
@@ -167,7 +167,7 @@
def deserialize(self, event, state):
obj = event.obj
- attrname = self.getAttrNameFor(obj)
+ attrname = self._get_attr_name_for(obj)
setattr(obj, attrname, state)
# Allow references under either attribute name.
event.deserialized('id', state)
@@ -181,11 +181,11 @@
__implements__ = ISerializer
schema = RowSequenceSchema()
- schema.addField('id', 'string', 1)
- schema.addField('type', 'string')
- schema.addField('data', 'string')
+ schema.add('id', 'string', 1)
+ schema.add('type', 'string')
+ schema.add('data', 'string')
- def canSerialize(self, obj):
+ def can_serialize(self, obj):
return isinstance(obj, PropertyManager)
def serialize(self, event):
=== Products/Ape/lib/apelib/zope2/scripts.py 1.4 => 1.5 ===
--- Products/Ape/lib/apelib/zope2/scripts.py:1.4 Mon Feb 2 10:07:23 2004
+++ Products/Ape/lib/apelib/zope2/scripts.py Sat Mar 20 01:34:25 2004
@@ -43,7 +43,7 @@
schema = FieldSchema('data', 'string')
- def canSerialize(self, obj):
+ def can_serialize(self, obj):
return isinstance(obj, PythonScript)
def serialize(self, event):
@@ -87,7 +87,7 @@
params_re = re.compile(r'\s*<params>(.*)</params>\s*\n', re.I | re.S)
- def canSerialize(self, obj):
+ def can_serialize(self, obj):
return isinstance(obj, SQL)
def serialize(self, event):
@@ -119,9 +119,9 @@
__implements__ = ISerializer
schema = RowSequenceSchema()
- schema.addField('id', 'string', 1)
- schema.addField('type', 'string')
- schema.addField('data', 'string')
+ schema.add('id', 'string', 1)
+ schema.add('type', 'string')
+ schema.add('data', 'string')
attributes = {
'title': str,
@@ -136,7 +136,7 @@
'connection_hook': str,
}
- def canSerialize(self, obj):
+ def can_serialize(self, obj):
return isinstance(obj, SQL)
def serialize(self, event):
=== Products/Ape/lib/apelib/zope2/security.py 1.5 => 1.6 ===
--- Products/Ape/lib/apelib/zope2/security.py:1.5 Tue Mar 16 23:02:18 2004
+++ Products/Ape/lib/apelib/zope2/security.py Sat Mar 20 01:34:25 2004
@@ -29,7 +29,7 @@
_permission_dict_cache = None
-def getPermissionDict():
+def get_permission_dict():
"""Returns a dictionary mapping permission attribute name to permission.
Does not discover permissions defined in ZClass products, since that
@@ -76,12 +76,12 @@
__implements__ = ISerializer
schema = RowSequenceSchema()
- schema.addField('declaration_type', 'string')
- schema.addField('role', 'string')
- schema.addField('permission', 'string')
- schema.addField('username', 'string')
+ schema.add('declaration_type', 'string')
+ schema.add('role', 'string')
+ schema.add('permission', 'string')
+ schema.add('username', 'string')
- def canSerialize(self, obj):
+ def can_serialize(self, obj):
return 1
def serialize(self, event):
@@ -121,7 +121,7 @@
for attr, value in obj.__dict__.items():
if attr.endswith('_Permission') and attr.startswith('_'):
if p_dict is None:
- p_dict = getPermissionDict()
+ p_dict = get_permission_dict()
p = p_dict.get(attr)
if p is not None:
event.ignore(attr)
@@ -227,12 +227,12 @@
__implements__ = ISerializer
schema = RowSequenceSchema()
- schema.addField('id', 'string', 1)
- schema.addField('password', 'string')
- schema.addField('roles', 'string:list')
- schema.addField('domains', 'string:list')
+ schema.add('id', 'string', 1)
+ schema.add('password', 'string')
+ schema.add('roles', 'string:list')
+ schema.add('domains', 'string:list')
- def canSerialize(self, obj):
+ def can_serialize(self, obj):
return isinstance(obj, UserFolder)
def serialize(self, event):
More information about the Zope-CVS
mailing list