Added schema field for internal references list
authorThierry Florac <thierry.florac@onf.fr>
Tue, 16 May 2017 11:21:09 +0200
changeset 7 29fcce505afe
parent 6 dd0072ed1543
child 8 5b3c9f7ef0d6
Added schema field for internal references list
src/pyams_sequence/schema.py
--- a/src/pyams_sequence/schema.py	Tue May 16 11:20:42 2017 +0200
+++ b/src/pyams_sequence/schema.py	Tue May 16 11:21:09 2017 +0200
@@ -16,17 +16,17 @@
 # import standard library
 
 # import interfaces
-from zope.schema.interfaces import ITextLine
+from zope.schema.interfaces import ITextLine, IList
 
 # import packages
 from zope.interface import implementer, Attribute
-from zope.schema import TextLine
+from zope.schema import TextLine, List
 
 
 class IInternalReference(ITextLine):
     """Internal reference field interface"""
 
-    content_type = Attribute("Requested content type")
+    content_type = Attribute("Requested target content type")
 
 
 @implementer(IInternalReference)
@@ -36,3 +36,20 @@
     def __init__(self, content_type=None, *args, **kwargs):
         super(InternalReference, self).__init__(*args, **kwargs)
         self.content_type = content_type
+
+
+class IInternalReferencesList(IList):
+    """Internal references list field interface"""
+
+    content_type = Attribute("Requested target content type")
+
+
+@implementer(IInternalReferencesList)
+class InternalReferencesList(List):
+    """Internal references list field"""
+
+    def __init__(self, content_type=None, value_type=None, unique=False, *args, **kwargs):
+        super(InternalReferencesList, self).__init__(value_type=TextLine(),
+                                                     unique=True,
+                                                     *args, **kwargs)
+        self.content_type = content_type