diff --git a/themis.fields.egg-info/SOURCES.txt b/themis.fields.egg-info/SOURCES.txt index 3ea6a13..29c16b1 100644 --- a/themis.fields.egg-info/SOURCES.txt +++ b/themis.fields.egg-info/SOURCES.txt @@ -7,8 +7,8 @@ themis.fields.egg-info/entry_points.txt themis.fields.egg-info/not-zip-safe themis.fields.egg-info/top_level.txt themisfields/__init__.py -themisfields/editor.py -themisfields/handler.py +themisfields/editors.py +themisfields/handlers.py themisfields/interfaces.py -themisfields/value.py -themisfields/widget.py \ No newline at end of file +themisfields/vocabs.py +themisfields/widgets.py \ No newline at end of file diff --git a/themisfields/__init__.py b/themisfields/__init__.py index 97e6e28..1e21683 100644 --- a/themisfields/__init__.py +++ b/themisfields/__init__.py @@ -1,4 +1,4 @@ -from zope.interface import implements +from zope.interface import implements, implementsOnly from zope.schema import Choice, Field, List, Date from zope.schema.interfaces import IFromUnicode @@ -12,6 +12,9 @@ from themisfields.vocabs import AuthorsSource from themisfields.interfaces import IAuthors +from themisfields.interfaces import IDate +from themisfields.interfaces import ISubjects, IList + class Commission(Field): implements(ICommission, IFromUnicode) @@ -71,3 +74,22 @@ class Authors(List): kw['unique'] = False super(Authors, self).__init__(**kw) + +from vocabs import SubjectsVocabulary, SubjectsVocabularyFactory +from vocabs import SubjectsSource + +class Subjects(Field): + implements(ISubjects, IList) + _type = list + + def __init__(self, **kw): + self.required = False + self.value_type = Choice(source=SubjectsSource()) + self.unique = True + self.min_length = None + self.max_length = None + + for attr in ('min_length', 'max_length', 'unique', 'value_type'): + if attr in kw: del kw[attr] + super(Subjects, self).__init__(**kw) + diff --git a/themisfields/configure.zcml b/themisfields/configure.zcml index d85d1e7..995bd5b 100644 --- a/themisfields/configure.zcml +++ b/themisfields/configure.zcml @@ -18,6 +18,9 @@ file="editors.zcml" /> + + +