On Mon, 2006-22-05 at 10:17 -0230, Rocky Burt wrote:
> I was just curious why zope.schema has fields for datetime.datetime,
> datetime.date, and datetime.timedelta but no field for datetime.time.  I
> have a need for such a field right now and I think it'd be useful to be
> core to zope.schema rather than me create my own field.

Ok, I've not committed anything worth recording into any sort of
changelog for zope3 before so I've attached the patch with all my
changes that I will be committing to Zope3 svn trunk shortly if no one
objects.  Did I modify the correct changelog and in the correct fashion?

- Rocky

Rocky Burt
ServerZen Software -- http://www.serverzen.com
News About The Server (blog) -- http://www.serverzen.net

Index: src/zope/schema/__init__.py
--- src/zope/schema/__init__.py	(revision 68240)
+++ src/zope/schema/__init__.py	(working copy)
@@ -21,7 +21,7 @@
 from zope.schema._field import Text, TextLine, Bool, Int, Float
 from zope.schema._field import Tuple, List, Set, FrozenSet
 from zope.schema._field import Password, Dict, Datetime, Date, Timedelta
-from zope.schema._field import SourceText
+from zope.schema._field import Time, SourceText
 from zope.schema._field import Object, URI, Id, DottedName
 from zope.schema._field import InterfaceField
 from zope.schema._schema import getFields, getFieldsInOrder
Index: src/zope/schema/_field.py
--- src/zope/schema/_field.py	(revision 68242)
+++ src/zope/schema/_field.py	(working copy)
@@ -19,7 +19,7 @@
 __docformat__ = 'restructuredtext'
 import re
-from datetime import datetime, date, timedelta
+from datetime import datetime, date, timedelta, time
 from sets import Set as SetType
 from zope.interface import classImplements, implements
@@ -33,6 +33,7 @@
 from zope.schema.interfaces import IBool, IInt, IFloat, IDatetime, IFrozenSet
 from zope.schema.interfaces import IChoice, ITuple, IList, ISet, IDict
 from zope.schema.interfaces import IPassword, IObject, IDate, ITimedelta
+from zope.schema.interfaces import ITime
 from zope.schema.interfaces import IURI, IId, IFromUnicode
 from zope.schema.interfaces import ISource, IBaseVocabulary
 from zope.schema.interfaces import IContextSourceBinder
@@ -183,6 +184,11 @@
     __doc__ = ITimedelta.__doc__
     _type = timedelta
+class Time(Orderable, Field):
+    __doc__ = ITime.__doc__
+    implements(ITime)
+    _type = time
 class Choice(Field):
     """Choice fields can have a value found in a constant or dynamic set of
Index: src/zope/schema/interfaces.py
--- src/zope/schema/interfaces.py	(revision 68240)
+++ src/zope/schema/interfaces.py	(working copy)
@@ -333,6 +333,9 @@
 class ITimedelta(IMinMax, IField):
     u"""Field containing a timedelta."""
+class ITime(IMinMax, IField):
+    u"""Field containing a time."""
 def _is_field(value):
     if not IField.providedBy(value):
         return False
Index: doc/CHANGES.txt
--- doc/CHANGES.txt	(revision 68240)
+++ doc/CHANGES.txt	(working copy)
@@ -10,6 +10,8 @@
     New features
+      - Added new Time field type to zope.schema
     Bug fixes

Attachment: signature.asc
Description: This is a digitally signed message part

Zope3-dev mailing list
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to