[Checkins] SVN: zope.schema/trunk/ - Add an interface for ``DottedName`` field
Dan Korostelev
nadako at gmail.com
Tue Mar 10 07:17:10 EDT 2009
Log message for revision 97796:
- Add an interface for ``DottedName`` field
Changed:
U zope.schema/trunk/CHANGES.txt
U zope.schema/trunk/src/zope/schema/_field.py
U zope.schema/trunk/src/zope/schema/interfaces.py
-=-
Modified: zope.schema/trunk/CHANGES.txt
===================================================================
--- zope.schema/trunk/CHANGES.txt 2009-03-10 10:51:18 UTC (rev 97795)
+++ zope.schema/trunk/CHANGES.txt 2009-03-10 11:17:10 UTC (rev 97796)
@@ -5,7 +5,7 @@
3.5.4 (unreleased)
------------------
-- ...
+- Add an interface for ``DottedName`` field.
3.5.3 (2009-03-10)
------------------
Modified: zope.schema/trunk/src/zope/schema/_field.py
===================================================================
--- zope.schema/trunk/src/zope/schema/_field.py 2009-03-10 10:51:18 UTC (rev 97795)
+++ zope.schema/trunk/src/zope/schema/_field.py 2009-03-10 11:17:10 UTC (rev 97796)
@@ -38,7 +38,7 @@
from zope.schema.interfaces import IPassword, IDate, ITimedelta
from zope.schema.interfaces import IObject, IBeforeObjectAssignedEvent
from zope.schema.interfaces import ITime, IDecimal
-from zope.schema.interfaces import IURI, IId, IFromUnicode
+from zope.schema.interfaces import IURI, IId, IDottedName, IFromUnicode
from zope.schema.interfaces import ISource, IBaseVocabulary
from zope.schema.interfaces import IContextSourceBinder
@@ -646,6 +646,8 @@
Values of DottedName fields must be Python-style dotted names.
"""
+ implements(IDottedName)
+
def __init__(self, *args, **kw):
"""
>>> DottedName(min_dots=-1)
@@ -665,6 +667,10 @@
>>> dotted_name = DottedName(max_dots=1, min_dots=1)
+ >>> from zope.interface.verify import verifyObject
+ >>> verifyObject(IDottedName, dotted_name)
+ True
+
>>> dotted_name = DottedName(max_dots=1)
>>> dotted_name.min_dots
0
Modified: zope.schema/trunk/src/zope/schema/interfaces.py
===================================================================
--- zope.schema/trunk/src/zope/schema/interfaces.py 2009-03-10 10:51:18 UTC (rev 97795)
+++ zope.schema/trunk/src/zope/schema/interfaces.py 2009-03-10 11:17:10 UTC (rev 97796)
@@ -362,6 +362,25 @@
If it's a dotted name, it should have a module/package name as a prefix.
"""
+class IDottedName(IBytesLine):
+ """Dotted name field.
+
+ Values of DottedName fields must be Python-style dotted names.
+ """
+
+ min_dots = Int(
+ title=_(u"Minimum number of dots"),
+ required=True,
+ min=0,
+ default=0
+ )
+
+ min_dots = Int(
+ title=_(u"Maximum number of dots (should not be less than min_dots)"),
+ required=False,
+ default=None
+ )
+
class IChoice(IField):
u"""Field whose value is contained in a predefined set
More information about the Checkins
mailing list