Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
161 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') |