[Zope-CVS] CVS: Products/AdaptableStorage/serial_ofs - OFSProperties.py:1.1.2.2 public.py:1.4.2.3
Christian Zagrodnick
cz@gocept.com
Thu, 23 Jan 2003 12:10:56 -0500
Update of /cvs-repository/Products/AdaptableStorage/serial_ofs
In directory cvs.zope.org:/tmp/cvs-serv14215/serial_ofs
Modified Files:
Tag: zagy-patches
OFSProperties.py public.py
Log Message:
merging HEAD into zagy-patches branch
=== Products/AdaptableStorage/serial_ofs/OFSProperties.py 1.1.2.1 => 1.1.2.2 ===
--- Products/AdaptableStorage/serial_ofs/OFSProperties.py:1.1.2.1 Mon Jan 13 14:46:29 2003
+++ Products/AdaptableStorage/serial_ofs/OFSProperties.py Thu Jan 23 12:10:23 2003
@@ -17,6 +17,7 @@
"""
from cPickle import dumps, loads
+from types import DictType
from mapper_public import IAspectSerializer, RowSequenceSchema
@@ -65,7 +66,15 @@
elif string_repr_types.get(t):
v = str(data)
else:
- v = dumps(data)
+ # Pickle the value and any extra info about the property.
+ # Extra info is present in select and multi-select properties.
+ d = p.copy()
+ del d['id']
+ del d['type']
+ if d.has_key('mode'):
+ del d['mode']
+ d['value'] = data
+ v = dumps(d)
res.append((name, t, v))
return res
@@ -74,7 +83,7 @@
assert object._properties is object._propertyMap()
old_props = object.propdict()
new_props = {}
- for id, t, data in state:
+ for id, t, v in state:
p = old_props.get(id)
if p is None:
p = {'mode': 'wd'}
@@ -82,6 +91,15 @@
p = p.copy()
p['id'] = id
p['type'] = t
+ if v and not string_repr_types.get(t) and t != 'lines':
+ # v is a pickle.
+ # Check the pickle for extra property info.
+ d = loads(v)
+ if isinstance(d, DictType):
+ del d['value']
+ if d:
+ # The data is stored with extra property info.
+ p.update(d)
new_props[id] = p
if old_props != new_props:
@@ -92,7 +110,15 @@
data = v.split('\n')
elif string_repr_types.get(t):
data = str(v)
+ elif v:
+ d = loads(v)
+ if isinstance(d, DictType):
+ # The data is stored with extra property info.
+ data = d['value']
+ else:
+ data = d
else:
- data = loads(v)
+ # Fall back to a default.
+ data = ''
object._updateProperty(id, data)
=== Products/AdaptableStorage/serial_ofs/public.py 1.4.2.2 => 1.4.2.3 ===