[Zope-CVS] CVS: Products/Ape/lib/apelib/zope2 - classifier.py:1.7
ofsserial.py:1.7
Shane Hathaway
shane at zope.com
Tue Feb 17 00:25:44 EST 2004
Update of /cvs-repository/Products/Ape/lib/apelib/zope2
In directory cvs.zope.org:/tmp/cvs-serv17338/lib/apelib/zope2
Modified Files:
classifier.py ofsserial.py
Log Message:
Another big pile of changes resulted from a little time. :-)
>From CHANGES.txt:
- Removed the concepts of "classified state" and "hints", now
relying on the existing concepts of classification and state. This
primarily involved changes to classifiers and the apelib.core.io
module.
- Implemented the folder item classification optimization. Now,
when Ape loads a folder, it passes along the classification of each
subitem as part of the containing folder's state. This means fewer
round-trips.
Also fixed a couple of shallow bugs that prevented Ape from starting in
Zope.
=== Products/Ape/lib/apelib/zope2/classifier.py 1.6 => 1.7 ===
--- Products/Ape/lib/apelib/zope2/classifier.py:1.6 Mon Feb 2 10:07:23 2004
+++ Products/Ape/lib/apelib/zope2/classifier.py Tue Feb 17 00:25:13 2004
@@ -79,7 +79,7 @@
"""
mapper_name = self.oid_to_mapper.get(event.oid)
if mapper_name is not None:
- return {'mapper_name': mapper_name}, mapper_name
+ return {'mapper_name': mapper_name}
klass = event.obj.__class__
class_name = '%s.%s' % (klass.__module__, klass.__name__)
classification = {'class_name': class_name}
@@ -92,11 +92,8 @@
else:
generic = 'file_object'
mapper_name = self.generic_to_mapper.get(generic)
- if mapper_name is not None:
- # Force a particular mapper
- classification['mapper_name'] = mapper_name
if mapper_name is None:
- raise SerializationError(
+ raise ClassificationError(
'No mapper known for class %s' % repr(class_name))
cta = self.options.get((mapper_name, 'content_type_attr'))
if cta is not None:
@@ -109,7 +106,8 @@
if ext:
classification['extension'] = ext
- return classification, mapper_name
+ classification['mapper_name'] = mapper_name
+ return classification
def classifyState(self, event):
@@ -117,7 +115,7 @@
"""
mapper_name = self.oid_to_mapper.get(event.oid)
if mapper_name is not None:
- return {'mapper_name': mapper_name}, mapper_name
+ return {'mapper_name': mapper_name}
classification, serial = self.gateway.load(event)
class_name = classification.get('class_name')
if class_name and ':' in class_name:
@@ -149,6 +147,8 @@
if not mapper_name:
mapper_name = self.generic_to_mapper.get('file')
if mapper_name is None:
- raise DeserializationError(
- 'No mapper known for class %s' % repr(class_name))
- return classification, mapper_name
+ raise ClassificationError(
+ 'No mapper known for oid %s' % repr(event.oid))
+
+ classification['mapper_name'] = mapper_name
+ return classification
=== Products/Ape/lib/apelib/zope2/ofsserial.py 1.6 => 1.7 ===
--- Products/Ape/lib/apelib/zope2/ofsserial.py:1.6 Mon Feb 2 10:07:23 2004
+++ Products/Ape/lib/apelib/zope2/ofsserial.py Tue Feb 17 00:25:13 2004
@@ -82,12 +82,14 @@
schema = RowSequenceSchema()
schema.addField('key', 'string', 1)
schema.addField('oid', 'string')
+ schema.addField('classification', 'classification')
# The fixed_oids flag must be turned on when serializing to
# an object system with meaningful OIDs (like the filesystem.)
# It doesn't need to be on for object systems with arbitrary
# OIDs such as SQL databases.
- fixed_oids = 1
+ def __init__(self, fixed_oids=1):
+ self.fixed_oids = fixed_oids
def canSerialize(self, obj):
return isinstance(obj, ObjectManager)
@@ -107,7 +109,8 @@
if oid is None:
oid = event.conf.oid_gen.new_oid(event, id, True)
event.referenced(id, base, True, oid)
- state.append((id, oid))
+ # No need to pass classification.
+ state.append((id, oid, None))
if self.fixed_oids:
event.ignore('_use_fixed_oids_')
# Add a marker that tells the folder it has to move/rename
@@ -117,11 +120,11 @@
def deserialize(self, event, state):
obj = event.obj
- assert isinstance(obj, ObjectManager)
+ assert isinstance(obj, ObjectManager), obj
if self.fixed_oids:
obj._use_fixed_oids_ = 1
- for (id, oid) in state:
- subob = event.resolve(id, oid)
+ for (id, oid, classification) in state:
+ subob = event.resolve(id, oid, classification)
setattr(obj, id, subob)
obj._objects += ({'id': id, 'meta_type':
subob.__class__.meta_type},)
More information about the Zope-CVS
mailing list