[Zope-CVS] CVS: Products/AdaptableStorage/serial_ofs - FilePData.py:1.2.2.4 FolderItems.py:1.9.2.4 FolderItemsByKeychain.py:1.2.2.4 IdAttribute.py:1.3.2.4 MetaTypeClassifier.py:1.11.2.1 OFSProperties.py:1.1.2.5 public.py:1.4.2.6
Christian Zagrodnick
cz@gocept.com
Thu, 6 Feb 2003 08:01:47 -0500
Update of /cvs-repository/Products/AdaptableStorage/serial_ofs
In directory cvs.zope.org:/tmp/cvs-serv14413/serial_ofs
Modified Files:
Tag: zagy-patches
FilePData.py FolderItems.py FolderItemsByKeychain.py
IdAttribute.py MetaTypeClassifier.py OFSProperties.py
public.py
Log Message:
merging HEAD into zagy-patches branch
=== Products/AdaptableStorage/serial_ofs/FilePData.py 1.2.2.3 => 1.2.2.4 ===
=== Products/AdaptableStorage/serial_ofs/FolderItems.py 1.9.2.3 => 1.9.2.4 ===
--- Products/AdaptableStorage/serial_ofs/FolderItems.py:1.9.2.3 Tue Feb 4 12:29:48 2003
+++ Products/AdaptableStorage/serial_ofs/FolderItems.py Thu Feb 6 08:01:14 2003
@@ -46,6 +46,10 @@
state = []
event.ignoreAttribute('_objects')
for id, subob in object.objectItems():
+ mp = getattr(subob, '_v_mount_point_', None)
+ if mp is not None:
+ # Store the mount point rather than the mounted object.
+ subob = mp[0]
base = aq_base(subob)
keychain = event.identifyObject(base)
expected = event.makeKeychain(id, 0)
=== Products/AdaptableStorage/serial_ofs/FolderItemsByKeychain.py 1.2.2.3 => 1.2.2.4 ===
--- Products/AdaptableStorage/serial_ofs/FolderItemsByKeychain.py:1.2.2.3 Tue Feb 4 12:29:48 2003
+++ Products/AdaptableStorage/serial_ofs/FolderItemsByKeychain.py Thu Feb 6 08:01:14 2003
@@ -45,6 +45,10 @@
state = []
event.ignoreAttribute('_objects')
for id, subob in object.objectItems():
+ mp = getattr(subob, '_v_mount_point_', None)
+ if mp is not None:
+ # Store the mount point rather than the mounted object.
+ subob = mp[0]
base = aq_base(subob)
keychain = event.identifyObject(base)
if keychain is None:
=== Products/AdaptableStorage/serial_ofs/IdAttribute.py 1.3.2.3 => 1.3.2.4 ===
=== Products/AdaptableStorage/serial_ofs/MetaTypeClassifier.py 1.11 => 1.11.2.1 ===
--- Products/AdaptableStorage/serial_ofs/MetaTypeClassifier.py:1.11 Tue Dec 31 16:47:50 2002
+++ Products/AdaptableStorage/serial_ofs/MetaTypeClassifier.py Thu Feb 6 08:01:14 2003
@@ -16,8 +16,6 @@
$Id$
"""
-import os
-
from Acquisition import aq_base
from OFS.ObjectManager import ObjectManager
@@ -34,6 +32,7 @@
self.gw = gw
self.key_to_res = {}
self.ext_to_mt = {}
+ self.mt_to_ext = {}
self.fmt_to_mt = {}
self.mt_to_mapper = {}
@@ -42,19 +41,28 @@
def register(self, meta_type, mapper_name, extensions=()):
+ """Registers a mapper to handle a Zope meta_type."""
for ext in extensions:
if not ext.startswith('.'):
ext = '.' + ext
ext = ext.lower()
self.ext_to_mt[ext] = meta_type
+ if extensions:
+ self.mt_to_ext[meta_type] = extensions[0]
self.mt_to_mapper[meta_type] = mapper_name
def registerKey(self, meta_type, mapper_name, key):
+ """Registers a mapper to handle a specific path.
+
+ For example, the application object mapper usually handles
+ the path '/'.
+ """
self.key_to_res[key] = ({'meta_type': meta_type}, mapper_name)
def registerDefaultLoader(self, meta_type, mapper_name, isdir):
+ """Registers a mapper to load unknown files or directories."""
if isdir:
ext = '<directory>'
else:
@@ -64,6 +72,7 @@
def registerDefaultStorage(self, meta_type, mapper_name, folderish):
+ """Registers a mapper to store unknown objects."""
if folderish:
fmt = 'folder'
else:
@@ -73,6 +82,7 @@
def classifyObject(self, value, keychain):
+ """Chooses a mapper and classification for storing an object."""
res = self.key_to_res.get(keychain[-1])
if res is not None:
return res
@@ -96,10 +106,14 @@
klass = value.__class__
ci = '%s:%s' % (klass.__module__, klass.__name__)
classification = {'meta_type': mt, 'class_name': ci}
+ ext = self.mt_to_ext.get(mt)
+ if ext:
+ classification['extension'] = ext
return classification, mapper_name
def classifyState(self, event):
+ """Chooses a mapper and classification for loading an object."""
keychain = event.getKeychain()
res = self.key_to_res.get(keychain[-1])
if res is not None:
@@ -113,15 +127,17 @@
mt = self.ext_to_mt.get('<directory>', 'Folder')
elif t == 'f':
# File
- filename = classification.get('filename')
- if filename:
- name, ext = os.path.splitext(filename)
+ ext = classification.get('extension')
+ if ext:
+ if not ext.startswith('.'):
+ ext = '.' + ext
mt = self.ext_to_mt.get(ext.lower())
- if not mt:
- mt = self.ext_to_mt.get('<file>', 'File')
+ if not mt:
+ mt = self.ext_to_mt.get('<file>', 'File')
else:
raise DeserializationError(
'No classification known for %s' % repr(keychain))
+ assert mt is not None
classification['meta_type'] = mt
mapper_name = self.mt_to_mapper.get(mt)
if mapper_name is None:
@@ -131,5 +147,6 @@
def store(self, event, classification):
+ """Stores the classification of an object."""
return self.gw.store(event, classification)
=== Products/AdaptableStorage/serial_ofs/OFSProperties.py 1.1.2.4 => 1.1.2.5 ===
=== Products/AdaptableStorage/serial_ofs/public.py 1.4.2.5 => 1.4.2.6 ===