[Checkins] SVN: z3c.schema/trunk/ Added new ``DateSelect`` field.

Stephan Richter srichter at cosmos.phy.tufts.edu
Fri Sep 21 09:05:02 EDT 2007


Log message for revision 79794:
  Added new ``DateSelect`` field.
  

Changed:
  A   z3c.schema/trunk/CHANGES.txt
  U   z3c.schema/trunk/setup.py
  _U  z3c.schema/trunk/src/
  A   z3c.schema/trunk/src/z3c/schema/dateselect/
  A   z3c.schema/trunk/src/z3c/schema/dateselect/README.txt
  A   z3c.schema/trunk/src/z3c/schema/dateselect/__init__.py
  A   z3c.schema/trunk/src/z3c/schema/dateselect/field.py
  A   z3c.schema/trunk/src/z3c/schema/dateselect/interfaces.py
  A   z3c.schema/trunk/src/z3c/schema/dateselect/tests.py

-=-
Added: z3c.schema/trunk/CHANGES.txt
===================================================================
--- z3c.schema/trunk/CHANGES.txt	                        (rev 0)
+++ z3c.schema/trunk/CHANGES.txt	2007-09-21 13:05:01 UTC (rev 79794)
@@ -0,0 +1,13 @@
+======================
+Changes for z3c.schema
+======================
+
+2007/09/21 0.2.0:
+=================
+
+- Feature: Added ``DateSelect`` field.
+
+2007/06/04 0.1.0:
+=================
+
+- Initial release


Property changes on: z3c.schema/trunk/CHANGES.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: z3c.schema/trunk/setup.py
===================================================================
--- z3c.schema/trunk/setup.py	2007-09-21 12:17:20 UTC (rev 79793)
+++ z3c.schema/trunk/setup.py	2007-09-21 13:05:01 UTC (rev 79794)
@@ -2,7 +2,7 @@
 from setuptools import setup, find_packages
 
 setup(name='z3c.schema',
-      version='0.1',
+      version='0.2',
       author = "Zope Community",
       author_email = "zope3-dev at zope.org",
       description = "Additional schema fields for Zope 3",


Property changes on: z3c.schema/trunk/src
___________________________________________________________________
Name: svn:ignore
   + z3c.schema.egg-info


Added: z3c.schema/trunk/src/z3c/schema/dateselect/README.txt
===================================================================
--- z3c.schema/trunk/src/z3c/schema/dateselect/README.txt	                        (rev 0)
+++ z3c.schema/trunk/src/z3c/schema/dateselect/README.txt	2007-09-21 13:05:01 UTC (rev 79794)
@@ -0,0 +1,35 @@
+========================
+The Date Selection Field
+========================
+
+The date selection field was designed to support the UI requirement of
+allowing users to select a date using multi-select input fields. The
+``DateSelect`` field extends the ``Date`` field merely by a few additional
+attributes.
+
+  >>> from z3c.schema.dateselect import field
+
+the first attribute is the range of years that will be offered to the user:
+
+  >>> birthday = field.DateSelect(
+  ...     title=u'Birthday',
+  ...     yearRange=range(1920, 2007))
+
+In this case the user will be offered all years from 1920 to 2007.
+
+  >>> birthday.yearRange
+  [1920, ..., 2006]
+
+The second attribute allows you to specify an initial date for the selection:
+
+  >>> import datetime
+  >>> birthday = field.DateSelect(
+  ...     title=u'Birthday',
+  ...     yearRange=range(1920, 2007),
+  ...     initialDate=datetime.date(2000, 1, 1))
+
+  >>> birthday.initialDate
+  datetime.date(2000, 1, 1)
+
+And this is really it. Please read the documentation on the ``Date`` for more
+information.


Property changes on: z3c.schema/trunk/src/z3c/schema/dateselect/README.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Added: z3c.schema/trunk/src/z3c/schema/dateselect/__init__.py
===================================================================
--- z3c.schema/trunk/src/z3c/schema/dateselect/__init__.py	                        (rev 0)
+++ z3c.schema/trunk/src/z3c/schema/dateselect/__init__.py	2007-09-21 13:05:01 UTC (rev 79794)
@@ -0,0 +1,19 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id$
+"""
+
+from z3c.schema.dateselect.interfaces import IDateSelect
+from z3c.schema.dateselect.field import DateSelect


Property changes on: z3c.schema/trunk/src/z3c/schema/dateselect/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: z3c.schema/trunk/src/z3c/schema/dateselect/field.py
===================================================================
--- z3c.schema/trunk/src/z3c/schema/dateselect/field.py	                        (rev 0)
+++ z3c.schema/trunk/src/z3c/schema/dateselect/field.py	2007-09-21 13:05:01 UTC (rev 79794)
@@ -0,0 +1,34 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Date Selection field implementation
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+import zope.interface
+import zope.schema
+
+from z3c.schema.dateselect import interfaces
+
+class DateSelect(zope.schema.Date):
+    zope.interface.implements(interfaces.IDateSelect)
+
+    yearRange = range(1900, 2100)
+    initialDate = None # set a date or today is used
+
+    def __init__(self, yearRange=None, initialDate=None, **kw):
+        super(DateSelect, self).__init__(**kw)
+        self.initialDate = initialDate
+        if yearRange is not None:
+            self.yearRange = yearRange


Property changes on: z3c.schema/trunk/src/z3c/schema/dateselect/field.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: z3c.schema/trunk/src/z3c/schema/dateselect/interfaces.py
===================================================================
--- z3c.schema/trunk/src/z3c/schema/dateselect/interfaces.py	                        (rev 0)
+++ z3c.schema/trunk/src/z3c/schema/dateselect/interfaces.py	2007-09-21 13:05:01 UTC (rev 79794)
@@ -0,0 +1,27 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Date Selection Field interfaces
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+
+import zope.schema.interfaces
+
+class IDateSelect(zope.schema.interfaces.IDate):
+
+    yearRange = zope.interface.Attribute(u"Year range.")
+
+    initialDate = zope.interface.Attribute(
+        u"Initial date displayed or ``None``. If ``None``, `today()`` is used.")


Property changes on: z3c.schema/trunk/src/z3c/schema/dateselect/interfaces.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: z3c.schema/trunk/src/z3c/schema/dateselect/tests.py
===================================================================
--- z3c.schema/trunk/src/z3c/schema/dateselect/tests.py	                        (rev 0)
+++ z3c.schema/trunk/src/z3c/schema/dateselect/tests.py	2007-09-21 13:05:01 UTC (rev 79794)
@@ -0,0 +1,32 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id$
+"""
+__docformat__ = "reStructuredText"
+
+import unittest
+from zope.testing import doctest
+from zope.testing.doctestunit import DocFileSuite
+
+
+def test_suite():
+    return unittest.TestSuite((
+        DocFileSuite('README.txt',
+            optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,),
+        ))
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')


Property changes on: z3c.schema/trunk/src/z3c/schema/dateselect/tests.py
___________________________________________________________________
Name: svn:keywords
   + Id



More information about the Checkins mailing list