[Zope-Checkins] CVS: Products/AdaptableStorage/mapper - FieldSchema.py:1.2 ObjectMapper.py:1.2 exceptions.py:1.2
Shane Hathaway
shane@zope.com
Mon, 6 Jan 2003 18:18:18 -0500
Update of /cvs-repository/Products/AdaptableStorage/mapper
In directory cvs.zope.org:/tmp/cvs-serv1755/mapper
Modified Files:
FieldSchema.py ObjectMapper.py exceptions.py
Log Message:
- Added a user folder mapper for the filesystem. SQL version coming
soon. (SQL tests fail at the moment.)
- Added unwriteData() to FSConnection. I may remove it later, since it turned
out I didn't need it.
- Made configuration errors easier to read.
- Added null implementations of certain interfaces.
- Added a default for FixedClassifier.
=== Products/AdaptableStorage/mapper/FieldSchema.py 1.1 => 1.2 ===
--- Products/AdaptableStorage/mapper/FieldSchema.py:1.1 Tue Dec 31 16:47:46 2002
+++ Products/AdaptableStorage/mapper/FieldSchema.py Mon Jan 6 18:17:44 2003
@@ -16,12 +16,19 @@
$Id$
"""
+from types import StringType
+
from interfaces.public import ISchema
-# ok_types just constrains the possible types until we figure out
-# what we really want to do here.
-ok_types = ('unicode', 'string', 'int', 'float', 'bool', 'object',
- 'classification', 'keychain')
+ok_types = ['unicode', 'string', 'int', 'float', 'bool', 'object',
+ 'classification', 'keychain', 'string:list']
+
+
+def addType(t):
+ """Adds an allowable field type."""
+ assert isinstance(t, StringType)
+ if t not in ok_types:
+ ok_types.append(t)
class FieldSchema:
=== Products/AdaptableStorage/mapper/ObjectMapper.py 1.1 => 1.2 ===
--- Products/AdaptableStorage/mapper/ObjectMapper.py:1.1 Tue Dec 31 16:47:46 2002
+++ Products/AdaptableStorage/mapper/ObjectMapper.py Mon Jan 6 18:17:44 2003
@@ -65,24 +65,24 @@
self._sub_mappers[name] = m
return m
- def checkConfiguration(self, names=(), recursive=1):
+ def checkConfiguration(self, path='root', recursive=1):
s = self._serializer
if s is None:
raise RuntimeError(
- 'No serializer configured for mapper %s' % repr(names))
+ 'No serializer configured for mapper %s' % repr(path))
if not IObjectSerializer.isImplementedBy(s):
raise RuntimeError(
'Not an IObjectSerializer: %s' % repr(s))
g = self._gateway
if g is None:
raise RuntimeError(
- 'No gateway configured for mapper %s' % repr(names))
+ 'No gateway configured for mapper %s' % repr(path))
if not IGateway.isImplementedBy(g):
raise RuntimeError(
'Not an IGateway: %s' % repr(g))
if s.getSchema() != g.getSchema():
raise RuntimeError('Mismatched schemas in mapper %s: %s != %s' % (
- repr(names), s.getSchema(), g.getSchema()))
+ repr(path), s.getSchema(), g.getSchema()))
if self._parent is None:
if self._classifier is None:
raise RuntimeError('No root classifier configured')
@@ -100,8 +100,8 @@
'Not an IObjectMapper: %s' % repr(self._parent))
if recursive:
- for name, m in self._sub_mappers.items():
- m.checkConfiguration((names + (name,)), recursive)
+ for n, m in self._sub_mappers.items():
+ m.checkConfiguration(('%s/%s' % (path, n)), recursive)
# IObjectMapper implementation
=== Products/AdaptableStorage/mapper/exceptions.py 1.1 => 1.2 ===
--- Products/AdaptableStorage/mapper/exceptions.py:1.1 Tue Dec 31 16:47:46 2002
+++ Products/AdaptableStorage/mapper/exceptions.py Mon Jan 6 18:17:44 2003
@@ -16,9 +16,12 @@
$Id$
"""
-class SerializationError(Exception):
+class MappingError(Exception):
+ """Object mapping exception"""
+
+class SerializationError(MappingError):
"""Error during serialization"""
-class DeserializationError(Exception):
+class DeserializationError(MappingError):
"""Error during deserialization"""