[Checkins] SVN: cipher.configstore/trunk/ Support `None` values in tuple/list/set types.
Adam Groszer
cvs-admin at zope.org
Sat Nov 24 09:34:43 UTC 2012
Log message for revision 128430:
Support `None` values in tuple/list/set types.
Changed:
U cipher.configstore/trunk/CHANGES.txt
U cipher.configstore/trunk/src/cipher/configstore/configstore.py
U cipher.configstore/trunk/src/cipher/configstore/configstore.txt
-=-
Modified: cipher.configstore/trunk/CHANGES.txt
===================================================================
--- cipher.configstore/trunk/CHANGES.txt 2012-11-23 15:26:31 UTC (rev 128429)
+++ cipher.configstore/trunk/CHANGES.txt 2012-11-24 09:34:42 UTC (rev 128430)
@@ -5,7 +5,7 @@
1.3.2 (unreleased)
------------------
-- Nothing changed yet.
+- Support `None` values in tuple/list/set types.
1.3.1 (2012-11-23)
Modified: cipher.configstore/trunk/src/cipher/configstore/configstore.py
===================================================================
--- cipher.configstore/trunk/src/cipher/configstore/configstore.py 2012-11-23 15:26:31 UTC (rev 128429)
+++ cipher.configstore/trunk/src/cipher/configstore/configstore.py 2012-11-24 09:34:42 UTC (rev 128430)
@@ -130,7 +130,14 @@
def load_type_List(self, unicode, field):
if not unicode.strip():
return []
- return [item.strip() for item in unicode.split(self.listValueSeparator)]
+ items = []
+ for item in unicode.split(self.listValueSeparator):
+ stripped = item.strip()
+ if stripped == NONE_VALUE_MARKER:
+ items.append(None)
+ else:
+ items.append(stripped)
+ return items
def load_type_Tuple(self, unicode, field):
return tuple(self.load_type_List(unicode, field))
@@ -224,7 +231,9 @@
return ''
def dump_type_Tuple(self, value, field):
- return self.listValueSeparator.join(value)
+ items = [NONE_VALUE_MARKER if i is None else i
+ for i in value]
+ return self.listValueSeparator.join(items)
dump_type_List = dump_type_Tuple
dump_type_Set = dump_type_Tuple
Modified: cipher.configstore/trunk/src/cipher/configstore/configstore.txt
===================================================================
--- cipher.configstore/trunk/src/cipher/configstore/configstore.txt 2012-11-23 15:26:31 UTC (rev 128429)
+++ cipher.configstore/trunk/src/cipher/configstore/configstore.txt 2012-11-24 09:34:42 UTC (rev 128430)
@@ -426,6 +426,12 @@
>>> store.load_type_List('one, two, three', field)
['one', 'two', 'three']
+ >>> store.dump_type_List(['one', None, 'three'], field)
+ u'one, <<<###NONE###>>>, three'
+
+ >>> store.load_type_List('one, <<<###NONE###>>>, three', field)
+ ['one', None, 'three']
+
>>> store.load_type_List('', field)
[]
@@ -440,6 +446,12 @@
>>> store.load_type_Tuple('one, two, three', field)
('one', 'two', 'three')
+ >>> store.dump_type_Tuple(('one', None, 'three'), field)
+ u'one, <<<###NONE###>>>, three'
+
+ >>> store.load_type_Tuple('one, <<<###NONE###>>>, three', field)
+ ('one', None, 'three')
+
>>> store.load_type_Tuple('', field)
()
@@ -454,5 +466,11 @@
>>> store.load_type_Set('one, two, three', field)
set(['three', 'two', 'one'])
+ >>> store.dump_type_Set(set(['one', None, 'three']), field)
+ u'<<<###NONE###>>>, three, one'
+
+ >>> store.load_type_Set('one, <<<###NONE###>>>, three', field)
+ set([None, 'three', 'one'])
+
>>> store.load_type_Set('', field)
set([])
More information about the checkins
mailing list