# HG changeset patch # User Thierry Florac # Date 1432118378 -7200 # Node ID c784991b55a465f5a585b36a4eadeb2725c43ac1 # Parent 31d5cfdbd74164c6a82b656af21df902ddd49bea Added persistent list and dict schema fields diff -r 31d5cfdbd741 -r c784991b55a4 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 #