[Zope-CVS] CVS: Products/Ape/lib/apelib/zope2 - apeconf.xml:1.6
classifier.py:1.8 ofsserial.py:1.8
Shane Hathaway
shane at zope.com
Sat Feb 28 15:07:00 EST 2004
Update of /cvs-repository/Products/Ape/lib/apelib/zope2
In directory cvs.zope.org:/tmp/cvs-serv30293/lib/apelib/zope2
Modified Files:
apeconf.xml classifier.py ofsserial.py
Log Message:
Merged ape-fs-oid-branch.
Ape now uses arbitrary OIDs on the filesystem, rather than using paths
as OIDs. This solves problems with moving and replacing objects and
further unifies SQL and filesystem databases.
=== Products/Ape/lib/apelib/zope2/apeconf.xml 1.5 => 1.6 ===
--- Products/Ape/lib/apelib/zope2/apeconf.xml:1.5 Thu Feb 19 01:44:06 2004
+++ Products/Ape/lib/apelib/zope2/apeconf.xml Sat Feb 28 15:06:29 2004
@@ -10,7 +10,7 @@
<classifier factory="apelib.zope2.classifier.Classifier">
<gateway factory="apelib.fs.classification.FSClassificationAnnotation" />
</classifier>
- <oid-generator factory="apelib.core.oidgen.PathOIDGenerator" />
+ <oid-generator factory="apelib.core.oidgen.SerialOIDGenerator" />
</variation>
<variation name="sql">
<classifier factory="apelib.zope2.classifier.Classifier">
@@ -28,12 +28,11 @@
<serializer name="roll_call" factory="apelib.zodb3.serializers.RollCall" />
<variation name="filesystem">
<gateway name="items" factory="apelib.fs.structure.root_mapping" />
- <use-for oid="/_root" />
</variation>
<variation name="sql">
<gateway name="items" factory="apelib.sql.structure.root_mapping" />
- <use-for oid="0" />
</variation>
+ <use-for oid="0" />
</mapper>
<!-- Abstract mappers -->
@@ -128,6 +127,8 @@
<serializer name="text" factory="apelib.core.serializers.StringDataAttribute"
param="_text" />
<gateway name="text" use="text_data" />
+ <serializer name="bindings" factory="apelib.core.serializers.IgnoredAttribute"
+ param="_bind_names" />
<use-for extensions=".html .htm .zpt .pt" />
</mapper>
@@ -196,9 +197,7 @@
<serializer name="id" enabled="false" />
<gateway name="id" enabled="false" />
<gateway name="items" use="dir_items" />
- <variation name="filesystem">
- <use-for oid="/" />
- </variation>
+ <use-for generic="basepath" />
</mapper>
<mapper name="anyfile">
@@ -209,4 +208,3 @@
</mapper>
</configuration>
-
=== Products/Ape/lib/apelib/zope2/classifier.py 1.7 => 1.8 ===
--- Products/Ape/lib/apelib/zope2/classifier.py:1.7 Tue Feb 17 00:25:13 2004
+++ Products/Ape/lib/apelib/zope2/classifier.py Sat Feb 28 15:06:29 2004
@@ -38,6 +38,9 @@
'application/octet-stream': '', # No extension--too overloaded.
}
+generic_classifications = (
+ 'directory', 'file', 'folder_object', 'file_object', 'basepath')
+
class Classifier:
"""A classifier with some minimal Zope 2 extensions.
@@ -60,8 +63,7 @@
elif condition == 'class':
self.class_to_mapper[value] = mapper_name
elif condition == 'generic':
- assert value in (
- 'directory', 'file', 'folder_object', 'file_object'), value
+ assert value in generic_classifications, value
self.generic_to_mapper[value] = mapper_name
elif condition == 'oid':
self.oid_to_mapper[value] = mapper_name
@@ -124,28 +126,37 @@
classification['class_name'] = class_name
mapper_name = classification.get('mapper_name')
if mapper_name is None:
- # bw compat: look for certain meta_types.
- mt = classification.get('meta_type')
- if mt == '(folderish object)':
- mapper_name = self.generic_to_mapper.get('folder_object')
- elif mt == '(fileish object)':
- mapper_name = self.generic_to_mapper.get('file_object')
- if mapper_name is None and class_name is not None:
- mapper_name = self.class_to_mapper.get(class_name)
- if mapper_name is None:
- t = classification.get('node_type')
- if t == 'd':
- # Directory
- mapper_name = self.generic_to_mapper.get('directory')
- elif t == 'f':
- # File
- ext = classification.get('extension')
- if ext:
- if not ext.startswith('.'):
- ext = '.' + ext
- mapper_name = self.ext_to_mapper.get(ext.lower())
- if not mapper_name:
- mapper_name = self.generic_to_mapper.get('file')
+ # The choice of mapper is not stored explicitly. Choose
+ # one based on several criteria.
+ if 1:
+ # bw compat: look for certain meta_types.
+ mt = classification.get('meta_type')
+ if mt == '(folderish object)':
+ mapper_name = self.generic_to_mapper.get('folder_object')
+ elif mt == '(fileish object)':
+ mapper_name = self.generic_to_mapper.get('file_object')
+ if mapper_name is None:
+ if class_name is not None:
+ mapper_name = self.class_to_mapper.get(class_name)
+ if mapper_name is None:
+ subpath = classification.get('subpath')
+ if subpath is not None and not subpath:
+ # Application base
+ mapper_name = self.generic_to_mapper.get('basepath')
+ if mapper_name is None:
+ t = classification.get('node_type')
+ if t == 'd':
+ # Directory
+ mapper_name = self.generic_to_mapper.get('directory')
+ elif t == 'f':
+ # File
+ ext = classification.get('extension')
+ if ext:
+ if not ext.startswith('.'):
+ ext = '.' + ext
+ mapper_name = self.ext_to_mapper.get(ext.lower())
+ if not mapper_name:
+ mapper_name = self.generic_to_mapper.get('file')
if mapper_name is None:
raise ClassificationError(
'No mapper known for oid %s' % repr(event.oid))
=== Products/Ape/lib/apelib/zope2/ofsserial.py 1.7 => 1.8 ===
--- Products/Ape/lib/apelib/zope2/ofsserial.py:1.7 Tue Feb 17 00:25:13 2004
+++ Products/Ape/lib/apelib/zope2/ofsserial.py Sat Feb 28 15:06:29 2004
@@ -84,13 +84,6 @@
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.
- def __init__(self, fixed_oids=1):
- self.fixed_oids = fixed_oids
-
def canSerialize(self, obj):
return isinstance(obj, ObjectManager)
@@ -111,18 +104,11 @@
event.referenced(id, base, True, 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
- # in a special way. The _setOb patch sees this attribute.
- obj._use_fixed_oids_ = 1
return state
def deserialize(self, event, state):
obj = event.obj
assert isinstance(obj, ObjectManager), obj
- if self.fixed_oids:
- obj._use_fixed_oids_ = 1
for (id, oid, classification) in state:
subob = event.resolve(id, oid, classification)
setattr(obj, id, subob)
More information about the Zope-CVS
mailing list