[Zope-CVS] CVS: Products/Ape/lib/apelib/core - classifiers.py:1.4
events.py:1.9 gateways.py:1.9 interfaces.py:1.13 io.py:1.10
schemas.py:1.6 serializers.py:1.6
Shane Hathaway
shane at zope.com
Sat Mar 20 01:34:53 EST 2004
Update of /cvs-repository/Products/Ape/lib/apelib/core
In directory cvs.zope.org:/tmp/cvs-serv19743/lib/apelib/core
Modified Files:
classifiers.py events.py gateways.py interfaces.py io.py
schemas.py serializers.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/core/classifiers.py 1.3 => 1.4 ===
--- Products/Ape/lib/apelib/core/classifiers.py:1.3 Tue Feb 17 00:25:11 2004
+++ Products/Ape/lib/apelib/core/classifiers.py Sat Mar 20 01:34:22 2004
@@ -37,16 +37,16 @@
else:
raise ConfigurationError("Unknown condition type: %s" % condition)
- def setOption(self, mapper_name, option, value):
+ def set_option(self, mapper_name, option, value):
raise ConfigurationError("No options available")
- def classifyObject(self, event):
+ def classify_object(self, event):
c = event.obj.__class__
class_name = "%s.%s" % (c.__module__, c.__name__)
mapper_name = self._class_to_mapper[class_name]
return {"class_name": class_name, "mapper_name": mapper_name}
- def classifyState(self, event):
+ def classify_state(self, event):
classification, serial = self.gateway.load(event)
class_name = classification["class_name"]
mapper_name = self._class_to_mapper[class_name]
=== Products/Ape/lib/apelib/core/events.py 1.8 => 1.9 ===
--- Products/Ape/lib/apelib/core/events.py:1.8 Tue Feb 17 00:25:11 2004
+++ Products/Ape/lib/apelib/core/events.py Sat Mar 20 01:34:22 2004
@@ -64,7 +64,7 @@
def classify(self, oid):
sub_event = LoadEvent(self.conf, None, oid, self.connections, None)
- return self.conf.classifier.classifyState(sub_event)
+ return self.conf.classifier.classify_state(sub_event)
class StoreEvent (GatewayEvent):
@@ -111,14 +111,14 @@
def resolve(self, name, oid, classification=None):
"""Retrieves a referenced subobject (usually ghosted initially).
"""
- ob = self.obj_db.getObject(oid, classification)
+ ob = self.obj_db.get(oid, classification)
self.external.append((oid, ob))
self.deserialized(name, ob)
return ob
# IFullDeserializationEvent interface methods:
- def resolveInternal(self, ref):
+ def resolve_internal(self, ref):
"""Returns an object already deserialized by another serializer.
'ref' is a tuple containing (serializer_name, name).
@@ -177,10 +177,10 @@
# IFullSerializationEvent interface methods:
- def getSerializedAttributeNames(self):
+ def get_seralized_attributes(self):
"""Returns the name of all attributes serialized."""
return self._attrs.keys()
- def identifyInternal(self, ob):
+ def identify_internal(self, ob):
"""Returns (serializer_name, name) or None."""
return self._internal_refs.get(id(ob))
=== Products/Ape/lib/apelib/core/gateways.py 1.8 => 1.9 ===
--- Products/Ape/lib/apelib/core/gateways.py:1.8 Mon Feb 2 10:07:18 2004
+++ Products/Ape/lib/apelib/core/gateways.py Sat Mar 20 01:34:22 2004
@@ -31,9 +31,9 @@
self._gws = {}
if base is not None:
self._gws.update(base._gws)
- self._updateSchema()
+ self._update_schema()
- def _updateSchema(self):
+ def _update_schema(self):
self.schema = {}
for name, gw in self._gws.items():
s = gw.schema
@@ -44,11 +44,11 @@
if not force and self._gws.has_key(name):
raise KeyError, "Gateway name %s in use" % name
self._gws[name] = gw
- self._updateSchema()
+ self._update_schema()
def remove(self, name):
del self._gws[name] # raise KeyError if not in use
- self._updateSchema()
+ self._update_schema()
def has(self, name):
return self._gws.has_key(name)
@@ -89,12 +89,12 @@
serials.sort()
return tuple(serials)
- def getPollSources(self, event):
+ def get_sources(self, event):
"""Returns data source information. See IGateway.
"""
res = {}
for gw in self._gws.values():
- sources = gw.getPollSources(event)
+ sources = gw.get_sources(event)
if sources is not None:
res.update(sources)
return res
@@ -121,6 +121,6 @@
self.data[event.oid] = (data, h)
return h
- def getPollSources(self, event):
+ def get_sources(self, event):
return None
=== Products/Ape/lib/apelib/core/interfaces.py 1.12 => 1.13 ===
--- Products/Ape/lib/apelib/core/interfaces.py:1.12 Wed Mar 17 19:12:30 2004
+++ Products/Ape/lib/apelib/core/interfaces.py Sat Mar 20 01:34:22 2004
@@ -47,7 +47,7 @@
class IClassFactory(Interface):
"""Class finder."""
- def getClass(module_name, class_name):
+ def get_class(module_name, class_name):
"""Returns the named class.
A default implementation may use the Python's standard import
@@ -62,7 +62,7 @@
an IObjectDatabase.
"""
- def getObject(oid, classification=None):
+ def get(oid, classification=None):
"""Returns a class instance, possibly ghosted.
Used during deserialization (loading/import).
@@ -201,7 +201,7 @@
"""Deserialization event with features for deserializing remainder data.
"""
- def resolveInternal(ref):
+ def resolve_internal(ref):
"""Returns the object identified by an intra-record reference.
'ref' is a tuple containing (serializer_name, name).
@@ -247,11 +247,11 @@
Used for generating a 'remainder pickle'.
"""
- def getSerializedAttributeNames():
+ def get_seralized_attributes():
"""Returns the names of all attributes serialized.
"""
- def identifyInternal(ob):
+ def identify_internal(ob):
"""Returns the intra-record reference for a subobject, if there is one.
Returns (serializer_name, name) or None.
@@ -263,7 +263,7 @@
schema = Attribute("schema", "The schema used by this component.")
- def canSerialize(obj):
+ def can_serialize(obj):
"""Returns true if this serializer can serialize the given object.
"""
@@ -294,11 +294,11 @@
and schema of its constituent ISerializers.
"""
- def createEmptyInstance(class_factory, classification=None):
+ def new_instance(class_factory, classification=None):
"""Returns a new instance.
If this serializer works with instances of only one class,
- createEmptyInstance() should not require the use of the
+ new_instance() should not require the use of the
classification argument. Implementations that need the
classification argument can return None when classification is
None, but doing so may incur a performance penalty.
@@ -343,7 +343,7 @@
Returns a new hash value.
"""
- def getPollSources(event):
+ def get_sources(event):
"""Returns source information for an OID. event is an IGatewayEvent.
The source information allows the system to poll for changes
@@ -363,10 +363,10 @@
"""Object classifier
Implementations of this interface are a little like biologists.
- During serialization, the classifyObject() method returns a
+ During serialization, the classify_object() method returns a
mapping containing the classification of subob (like a biologist
identifying a creature's genus and species). During
- deserialization, the classifyState() method decides what kind of
+ deserialization, the classify_state() method decides what kind of
objects to create for a stored state (like a biologist showing you
a creature of a certain genus and species).
@@ -380,14 +380,14 @@
object by calling gateway.store().
""")
- def classifyObject(event):
+ def classify_object(event):
"""Returns a classification with at least a mapper_name.
event is an ILoadEvent without a mapper or classification
(since this method chooses them).
"""
- def classifyState(event):
+ def classify_state(event):
"""Returns a classification with at least a mapper_name.
event is an ILoadEvent without a mapper or classification
@@ -416,7 +416,7 @@
and 'folder_object'.
"""
- def setOption(mapper_name, option, value):
+ def set_option(mapper_name, option, value):
"""Sets a classification option pertaining to a particular mapper.
As an example, the zope2 classifier allows at least two options:
@@ -499,6 +499,10 @@
class ITPCConnection(Interface):
+ """Connection involved in minimal two-phase commit.
+
+ Based on ZODB.Transaction.
+ """
def connect():
"""Opens any resources needed for transactions. Called only once."""
=== Products/Ape/lib/apelib/core/io.py 1.9 => 1.10 ===
--- Products/Ape/lib/apelib/core/io.py:1.9 Wed Mar 17 19:17:00 2004
+++ Products/Ape/lib/apelib/core/io.py Sat Mar 20 01:34:22 2004
@@ -48,7 +48,7 @@
conn_list.append(c)
self.conn_list = conn_list
- def openConnections(self):
+ def open_connections(self):
try:
opened = []
for c in self.conn_list:
@@ -59,17 +59,17 @@
c.close()
raise
- def closeConnections(self):
+ def close_connections(self):
for conn in self.conn_list:
conn.close()
- def getConnectionList(self):
+ def get_connection_list(self):
return self.conn_list
- def getConnectionMap(self):
+ def get_connection_map(self):
return self.conn_map
- def initDatabases(self, clear_all=0):
+ def init_databases(self, clear_all=0):
"""Creates tables, etc.
"""
# Find all initializers, eliminating duplicates.
@@ -85,13 +85,13 @@
for initializer in initializers.keys():
initializer.init(event)
- def classifyState(self, oid):
+ def classify_state(self, oid):
event = LoadEvent(self.conf, None, oid, self.conn_map, None)
# Returns classification
- return self.conf.classifier.classifyState(event)
+ return self.conf.classifier.classify_state(event)
def load(self, oid):
- classification = self.classifyState(oid)
+ classification = self.classify_state(oid)
mapper_name = classification['mapper_name']
mapper = self.conf.mappers[mapper_name]
event = LoadEvent(self.conf, mapper, oid, self.conn_map, classification)
@@ -109,16 +109,16 @@
new_hash = mapper.gateway.store(event, state)
return event, new_hash
- def getPollSources(self, oid):
+ def get_sources(self, oid):
try:
- classification = self.classifyState(oid)
+ classification = self.classify_state(oid)
except LoadError:
# Doesn't exist.
return {}
mapper_name = classification['mapper_name']
mapper = self.conf.mappers[mapper_name]
event = LoadEvent(self.conf, mapper, oid, self.conn_map, classification)
- return mapper.gateway.getPollSources(event)
+ return mapper.gateway.get_sources(event)
def new_oid(self):
event = GatewayEvent(self.conf, None, None, self.conn_map, None)
@@ -135,13 +135,13 @@
self.conf = conf
self.obj_db = obj_db
- def classifyObject(self, obj, oid):
+ def classify_object(self, obj, oid):
event = SerializationEvent(self.conf, None, oid, self.obj_db, obj)
# Returns classification
- return self.conf.classifier.classifyObject(event)
+ return self.conf.classifier.classify_object(event)
def serialize(self, oid, obj):
- classification = self.classifyObject(obj, oid)
+ classification = self.classify_object(obj, oid)
mapper_name = classification['mapper_name']
mapper = self.conf.mappers[mapper_name]
event = SerializationEvent(self.conf, mapper, oid, self.obj_db, obj)
@@ -155,10 +155,10 @@
mapper.serializer.deserialize(event, state)
return event
- def newObject(self, classification):
+ def new_instance(self, classification):
mapper_name = classification['mapper_name']
mapper = self.conf.mappers[mapper_name]
- return mapper.serializer.createEmptyInstance(
+ return mapper.serializer.new_instance(
self.obj_db, classification=classification)
@@ -205,7 +205,7 @@
return is_new
- def exportObject(self, src_obj, dest_oid=None, deactivate_func=None):
+ def export_object(self, src_obj, dest_oid=None, deactivate_func=None):
count = 0
if dest_oid is None:
dest_oid = self.new_oid()
@@ -226,10 +226,10 @@
todo.append((ext_oid, ext_obj))
- def importObject(self, src_oid, dest_obj=None, commit_func=None):
+ def import_object(self, src_oid, dest_obj=None, commit_func=None):
count = 0
if dest_obj is None:
- dest_obj = self.getObject(src_oid)
+ dest_obj = self.get(src_oid)
root_obj = dest_obj
self._register(src_oid, dest_obj)
# Import subobjects.
@@ -254,22 +254,22 @@
# IObjectDatabase implementation
- def getClass(self, module, name):
+ def get_class(self, module, name):
# Normally called only while importing
if self._class_factory is not None:
- return self._class_factory.getClass(module, name)
+ return self._class_factory.get_class(module, name)
else:
m = __import__(module, {}, {}, ('__doc__',))
return getattr(m, name)
- def getObject(self, oid, classification=None):
+ def get(self, oid, classification=None):
# Should be called only while importing
try:
return self._objects[oid]
except KeyError:
# This object has not been loaded yet. Make a stub.
e, classification, state, hash_value = self.gw_io.load(oid)
- obj = self.obj_io.newObject(classification)
+ obj = self.obj_io.new_instance(classification)
# Don't fill in the state yet, to avoid infinite
# recursion. Just register it.
self._incomplete[oid] = 1
=== Products/Ape/lib/apelib/core/schemas.py 1.5 => 1.6 ===
--- Products/Ape/lib/apelib/core/schemas.py:1.5 Mon Feb 2 10:07:18 2004
+++ Products/Ape/lib/apelib/core/schemas.py Sat Mar 20 01:34:22 2004
@@ -22,7 +22,7 @@
'classification', 'string:list', 'blob']
-def addFieldType(t):
+def add_field_type(t):
"""Adds an allowable field type."""
assert isinstance(t, StringType)
if t not in ok_types:
@@ -39,7 +39,7 @@
self.type = type
self.unique = not not unique
- def getColumnDefs(self):
+ def get_column_defs(self):
return [(self.name, self.type, self.unique)]
def __eq__(self, other):
@@ -68,10 +68,10 @@
for c in fields:
self._add(c)
- def getColumnDefs(self):
+ def get_column_defs(self):
res = []
for f in self.fields:
- res.extend(f.getColumnDefs())
+ res.extend(f.get_column_defs())
return tuple(res)
def _add(self, c):
@@ -80,7 +80,7 @@
self.field_names[c.name] = 1
self.fields.append(c)
- def addField(self, name, type='string', unique=0):
+ def add(self, name, type='string', unique=0):
self._add(FieldSchema(name, type, unique))
def __eq__(self, other):
=== Products/Ape/lib/apelib/core/serializers.py 1.5 => 1.6 ===
--- Products/Ape/lib/apelib/core/serializers.py:1.5 Mon Feb 2 10:07:18 2004
+++ Products/Ape/lib/apelib/core/serializers.py Sat Mar 20 01:34:22 2004
@@ -42,11 +42,11 @@
self._part_names.update(base._part_names)
self._parts[:] = base._parts
self._final_parts[:] = base._final_parts
- self._updateSchema()
+ self._update_schema()
- def _updateSchema(self):
+ def _update_schema(self):
self.schema = {}
- for name, serializer in self.getSerializers():
+ for name, serializer in self.get_serializers():
s = serializer.schema
if s is not None:
self.schema[name] = s
@@ -61,7 +61,7 @@
else:
self._parts.append((name, serializer))
self._part_names[name] = 1
- self._updateSchema()
+ self._update_schema()
def remove(self, name):
if not self._part_names.has_key(name):
@@ -72,15 +72,15 @@
del lst[i]
break
del self._part_names[name]
- self._updateSchema()
+ self._update_schema()
def has(self, name):
return self._part_names.has_key(name)
- def getSerializers(self):
+ def get_serializers(self):
return self._parts + self._final_parts
- def canSerialize(self, obj):
+ def can_serialize(self, obj):
if not hasattr(obj, '__class__'):
return 0
c = obj.__class__
@@ -88,7 +88,7 @@
def serialize(self, event):
full_state = {}
- for name, s in self.getSerializers():
+ for name, s in self.get_serializers():
event.serializer_name = name
state = s.serialize(event)
if state is not None:
@@ -96,13 +96,13 @@
return full_state
def deserialize(self, event, full_state):
- for name, s in self.getSerializers():
+ for name, s in self.get_serializers():
state = full_state.get(name)
event.serializer_name = name
s.deserialize(event, state)
- def createEmptyInstance(self, class_factory, classification=None):
- c = class_factory.getClass(self._module, self._name)
+ def new_instance(self, class_factory, classification=None):
+ c = class_factory.get_class(self._module, self._name)
return c.__basicnew__()
@@ -114,10 +114,10 @@
def __init__(self, base=None):
self.init(base)
- def canSerialize(self, obj):
+ def can_serialize(self, obj):
return 1
- def createEmptyInstance(self, class_factory, classification=None):
+ def new_instance(self, class_factory, classification=None):
if classification is None:
# This serializer can't do anything without the classification.
return None
@@ -127,7 +127,7 @@
raise ValueError, "class_name must include the module"
module = cn[:pos]
name = cn[pos + 1:]
- c = class_factory.getClass(module, name)
+ c = class_factory.get_class(module, name)
if hasattr(c, "__basicnew__"): # ExtensionClass
return c.__basicnew__()
else:
@@ -141,7 +141,7 @@
schema = FieldSchema('data', 'object')
- def canSerialize(self, obj):
+ def can_serialize(self, obj):
return 1
def serialize(self, event):
@@ -161,7 +161,7 @@
def __init__(self, attrname):
self.attrname = attrname
- def canSerialize(self, obj):
+ def can_serialize(self, obj):
return 1
def serialize(self, event):
@@ -184,17 +184,17 @@
self._default_state = default_state
self.schema = real.schema
- def canSerialize(self, obj):
+ def can_serialize(self, obj):
return 1
def serialize(self, event):
- if self._real.canSerialize(event.obj):
+ if self._real.can_serialize(event.obj):
return self._real.serialize(event)
else:
return self._default_state
def deserialize(self, event, state):
- if self._real.canSerialize(event.obj):
+ if self._real.can_serialize(event.obj):
self._real.deserialize(event, state)
else:
if state is not None and state != self._default_state:
@@ -213,7 +213,7 @@
def __init__(self, attrname):
self.attrname = attrname
- def canSerialize(self, object):
+ def can_serialize(self, object):
return 1
def serialize(self, event):
More information about the Zope-CVS
mailing list