Added persistent list and dict schema fields
authorThierry Florac <thierry.florac@onf.fr>
Wed, 20 May 2015 12:39:38 +0200 (2015-05-20)
changeset 32 c784991b55a4
parent 31 31d5cfdbd741
child 33 e1aca8c25e61
Added persistent list and dict schema fields
src/pyams_utils/schema.py
--- a/src/pyams_utils/schema.py	Wed May 20 12:39:05 2015 +0200
+++ b/src/pyams_utils/schema.py	Wed May 20 12:39:38 2015 +0200
@@ -17,11 +17,13 @@
 import string
 
 # import interfaces
-from zope.schema.interfaces import ITextLine, IDecimal, IList, ITuple, IPassword
+from zope.schema.interfaces import ITextLine, IDecimal, IList, IDict, ITuple, IPassword
 
 # import Zope3 packages
+from persistent.list import PersistentList as PersistentListType
+from persistent.mapping import PersistentMapping
 from zope.interface import implementer
-from zope.schema import TextLine, Decimal, List, Tuple, Password, ValidationError
+from zope.schema import TextLine, Decimal, List, Dict, Tuple, Password, ValidationError
 
 # import local packages
 
@@ -29,6 +31,36 @@
 
 
 #
+# Persistent list field
+#
+
+class IPersistentList(IList):
+    """Persistent list field marker interface"""
+
+
+@implementer(IPersistentList)
+class PersistentList(List):
+    """Persistent list field"""
+
+    _type = PersistentListType
+
+
+#
+# Persistent mapping field
+#
+
+class IPersistentDict(IDict):
+    """Persistent mapping field marker interface"""
+
+
+@implementer(IPersistentDict)
+class PersistentDict(Dict):
+    """Persistent mapping field"""
+
+    _type = PersistentMapping
+
+
+#
 # Encoded password field
 #