[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Formulator/Widgets/Browser - datetime.pt:1.1.2.1 DateTimeWidget.py:1.1.2.2.2.1 TextAreaWidget.py:1.1.2.2.2.1
Stephan Richter
srichter@cbu.edu
Mon, 4 Mar 2002 01:05:26 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser
In directory cvs.zope.org:/tmp/cvs-serv27951/Widgets/Browser
Modified Files:
Tag: srichter-OFS_Formulator-branch
DateTimeWidget.py TextAreaWidget.py
Added Files:
Tag: srichter-OFS_Formulator-branch
datetime.pt
Log Message:
- Started implementation of CompositeWidget. Note that CompositeField or
CompositeValidator don't make sense in the Zope 3 Formulator.
ToDo
- Finish up CompositeWidget
- Write tests
- Write a tutorial on how to use Formualtor in Zope 3
- Start implementing Converters, which are objects that convert protocol
native data into a basic presentable Python fornat. Note, that in Zope 2
the Validator was responsible for that as well. --> This was decided upon
by Steve A., Kapil K. and Stephan R. in the zope3-dev IRC channel.
=== Added File Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/datetime.pt ===
<input> / <input> / <input> <input> : <input> : <input?
=== Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/DateTimeWidget.py 1.1.2.2 => 1.1.2.2.2.1 ===
#
-# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
@@ -15,73 +16,33 @@
$Id$
"""
+from Zope.PageTemplate.PageTemplateFile import PageTemplateFile
from Widget import Widget
from DateTime import DateTime
+class DateTimeWidget(CompositeWidget):
-class DateTimeWidget(Widget):
- property_names = Widget.property_names +\
- ['defaultNow', 'dateSeparator', 'timeSeparator',
- 'inputStyle', 'inputOrder',
- 'dateOnly']
+
+ __implements__ = CompositeWidget.__implements__
+
+
+ propertyNames = Widget.property_names +\
+ ['dateSeparator', 'timeSeparator',
+ 'inputStyle', 'inputOrder', 'dateOnly']
+
+ template = PageTemplateFile('datetime.pt')
+
+ widgets = {'year': IntegerWidget(start=0, end=6000),
+ 'month': IntegerWidget(start=0, end=12),
+ 'day': IntegerWidget(start=0, end=31),
+ 'hour': IntegerWidget(start=0, end=23),
+ 'minute': IntegerWidget(start=0, end=59)}
default = None
defaultNow = 0
dateSeparator = '/'
timeSeparator = ':'
inputStyle = "text"
- inputOrder = "ymd"
+ inputOrder = ('year', 'month', 'day')
dateOnly = 0
-
- # FIXME: do we want to handle 'extra'?
-
- def render(self, REQUEST=None):
- # FIXME: backwards compatibility hack:
- if not hasattr(field, 'sub_form'):
- from StandardFields import create_datetime_text_sub_form
- field.sub_form = create_datetime_text_sub_form()
-
- if value is None and field.get_value('default_now'):
- value = DateTime()
-
- if value is None:
- year = None
- month = None
- day = None
- hour = None
- minute = None
- else:
- year = "%04d" % value.year()
- month = "%02d" % value.month()
- day = "%02d" % value.day()
- hour = "%02d" % value.hour()
- minute = "%02d" % value.minute()
-
- input_order = field.get_value('input_order')
- if input_order == 'ymd':
- order = [('year', year),
- ('month', month),
- ('day', day)]
- elif input_order == 'dmy':
- order = [('day', day),
- ('month', month),
- ('year', year)]
- elif input_order == 'mdy':
- order = [('month', month),
- ('day', day),
- ('year', year)]
- result = []
- for sub_field_name, sub_field_value in order:
- result.append(field.render_sub_field(sub_field_name,
- sub_field_value, REQUEST))
- date_result = string.join(result, field.get_value('date_separator'))
- if not field.get_value('date_only'):
- time_result = (field.render_sub_field('hour', hour, REQUEST) +
- field.get_value('time_separator') +
- field.render_sub_field('minute', minute, REQUEST))
- return date_result + ' ' + time_result
- else:
- return date_result
-
-DateTimeWidgetInstance = DateTimeWidget()
=== Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/TextAreaWidget.py 1.1.2.2 => 1.1.2.2.2.1 ===
default = ""
- width = 30
- height = 6
+ width = 80
+ height = 15
extra=""
def render(self, REQUEST=None):