[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Formulator/Fields/Generic - DateTimeField.py:1.1.4.2 EmailField.py:1.1.4.2 FileField.py:1.1.4.2 FloatField.py:1.1.4.2 IntegerField.py:1.1.4.2 LinkField.py:1.1.4.2 ListField.py:1.1.4.2 PasswordField.py:1.1.4.2 PatternField.py:1.1.4.2 StringField.py:1.1.4.2
Jeremy Hylton
jeremy@zope.com
Tue, 4 Jun 2002 12:28:18 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/Formulator/Fields/Generic
In directory cvs.zope.org:/tmp/cvs-serv4032/Fields/Generic
Modified Files:
Tag: Zope-3x-branch
DateTimeField.py EmailField.py FileField.py FloatField.py
IntegerField.py LinkField.py ListField.py PasswordField.py
PatternField.py StringField.py
Log Message:
Fix line endings
=== Zope3/lib/python/Zope/App/Formulator/Fields/Generic/DateTimeField.py 1.1.4.1 => 1.1.4.2 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-from Zope.App.Formulator.Field import Field
-from Zope.App.Formulator.Validators import DateTimeValidator
-import time
-
-
-class DateTimeField(Field):
-
- __implements__ = Field.__implements__
-
- id = None
- default = ''
- title = 'DateTime Field'
- description = 'DateTime Field'
- validator = DateTimeValidator.DateTimeValidator()
-
-
- def on_value_input_style_changed(self, value):
- if value == 'text':
- self.sub_form = create_datetime_text_sub_form()
- elif value == 'list':
- self.sub_form = create_datetime_list_sub_form()
- year_field = self.sub_form.get_field('year')
- year_field.overrides['items'] = BoundMethod(self,
- 'override_year_items')
- else:
- assert 0, "Unknown input_style."
-
- def override_year_items(self):
- """The method gets called to get the right amount of years.
- """
- start_datetime = self.get_value('start_datetime')
- end_datetime = self.get_value('end_datetime')
- current_year = time.gmtime(time.time())[0]
- if start_datetime:
- first_year = start_datetime.year()
- else:
- first_year = current_year
- if end_datetime:
- last_year = end_datetime.year() + 1
- else:
- last_year = first_year + 11
- return create_items(first_year, last_year, digits=4)
-
-
-def create_datetime_text_sub_form():
- sub_form = BasicForm()
-
- year = IntegerField('year',
- title="Year",
- required=0,
- display_width=4,
- display_maxwidth=4,
- max_length=4)
-
- month = IntegerField('month',
- title="Month",
- required=0,
- display_width=2,
- display_maxwidth=2,
- max_length=2)
-
- day = IntegerField('day',
- title="Day",
- required=0,
- display_width=2,
- display_maxwidth=2,
- max_length=2)
-
- sub_form.add_group("date")
- sub_form.add_fields([year, month, day], "date")
-
- hour = IntegerField('hour',
- title="Hour",
- required=0,
- display_width=2,
- display_maxwidth=2,
- max_length=2)
-
- minute = IntegerField('minute',
- title="Minute",
- required=0,
- display_width=2,
- display_maxwidth=2,
- max_length=2)
-
- sub_form.add_group("time")
- sub_form.add_fields([hour, minute], "time")
- return sub_form
-
-
-def create_datetime_list_sub_form():
- sub_form = BasicForm()
-
- year = ListField('year',
- title="Year",
- required=0,
- default="",
- items=create_items(2000, 2010, digits=4),
- size=1)
-
- month = ListField('month',
- title="Month",
- required=0,
- default="",
- items=create_items(1, 13, digits=2),
- size=1)
-
- day = ListField('day',
- title="Day",
- required=0,
- default="",
- items=create_items(1, 32, digits=2),
- size=1)
-
- sub_form.add_group("date")
- sub_form.add_fields([year, month, day], "date")
-
- hour = IntegerField('hour',
- title="Hour",
- required=0,
- display_width=2,
- display_maxwidth=2,
- max_length=2)
-
- minute = IntegerField('minute',
- title="Minute",
- required=0,
- display_width=2,
- display_maxwidth=2,
- max_length=2)
-
- sub_form.add_group("time")
- sub_form.add_fields([hour, minute], "time")
- return sub_form
-
-def create_items(start, end, digits=0):
- result = [("-", "")]
- if digits:
- format_string = "%0" + str(digits) + "d"
- else:
- format_string = "%s"
-
- for i in range(start, end):
- s = format_string % i
- result.append((s, s))
- return result
+"""
+
+$Id$
+"""
+
+from Zope.App.Formulator.Field import Field
+from Zope.App.Formulator.Validators import DateTimeValidator
+import time
+
+
+class DateTimeField(Field):
+
+ __implements__ = Field.__implements__
+
+ id = None
+ default = ''
+ title = 'DateTime Field'
+ description = 'DateTime Field'
+ validator = DateTimeValidator.DateTimeValidator()
+
+
+ def on_value_input_style_changed(self, value):
+ if value == 'text':
+ self.sub_form = create_datetime_text_sub_form()
+ elif value == 'list':
+ self.sub_form = create_datetime_list_sub_form()
+ year_field = self.sub_form.get_field('year')
+ year_field.overrides['items'] = BoundMethod(self,
+ 'override_year_items')
+ else:
+ assert 0, "Unknown input_style."
+
+ def override_year_items(self):
+ """The method gets called to get the right amount of years.
+ """
+ start_datetime = self.get_value('start_datetime')
+ end_datetime = self.get_value('end_datetime')
+ current_year = time.gmtime(time.time())[0]
+ if start_datetime:
+ first_year = start_datetime.year()
+ else:
+ first_year = current_year
+ if end_datetime:
+ last_year = end_datetime.year() + 1
+ else:
+ last_year = first_year + 11
+ return create_items(first_year, last_year, digits=4)
+
+
+def create_datetime_text_sub_form():
+ sub_form = BasicForm()
+
+ year = IntegerField('year',
+ title="Year",
+ required=0,
+ display_width=4,
+ display_maxwidth=4,
+ max_length=4)
+
+ month = IntegerField('month',
+ title="Month",
+ required=0,
+ display_width=2,
+ display_maxwidth=2,
+ max_length=2)
+
+ day = IntegerField('day',
+ title="Day",
+ required=0,
+ display_width=2,
+ display_maxwidth=2,
+ max_length=2)
+
+ sub_form.add_group("date")
+ sub_form.add_fields([year, month, day], "date")
+
+ hour = IntegerField('hour',
+ title="Hour",
+ required=0,
+ display_width=2,
+ display_maxwidth=2,
+ max_length=2)
+
+ minute = IntegerField('minute',
+ title="Minute",
+ required=0,
+ display_width=2,
+ display_maxwidth=2,
+ max_length=2)
+
+ sub_form.add_group("time")
+ sub_form.add_fields([hour, minute], "time")
+ return sub_form
+
+
+def create_datetime_list_sub_form():
+ sub_form = BasicForm()
+
+ year = ListField('year',
+ title="Year",
+ required=0,
+ default="",
+ items=create_items(2000, 2010, digits=4),
+ size=1)
+
+ month = ListField('month',
+ title="Month",
+ required=0,
+ default="",
+ items=create_items(1, 13, digits=2),
+ size=1)
+
+ day = ListField('day',
+ title="Day",
+ required=0,
+ default="",
+ items=create_items(1, 32, digits=2),
+ size=1)
+
+ sub_form.add_group("date")
+ sub_form.add_fields([year, month, day], "date")
+
+ hour = IntegerField('hour',
+ title="Hour",
+ required=0,
+ display_width=2,
+ display_maxwidth=2,
+ max_length=2)
+
+ minute = IntegerField('minute',
+ title="Minute",
+ required=0,
+ display_width=2,
+ display_maxwidth=2,
+ max_length=2)
+
+ sub_form.add_group("time")
+ sub_form.add_fields([hour, minute], "time")
+ return sub_form
+
+def create_items(start, end, digits=0):
+ result = [("-", "")]
+ if digits:
+ format_string = "%0" + str(digits) + "d"
+ else:
+ format_string = "%s"
+
+ for i in range(start, end):
+ s = format_string % i
+ result.append((s, s))
+ return result
=== Zope3/lib/python/Zope/App/Formulator/Fields/Generic/EmailField.py 1.1.4.1 => 1.1.4.2 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-from Zope.App.Formulator.Field import Field
-from Zope.App.Formulator.Validators import EmailValidator
-
-
-class EmailField(Field):
-
- __implements__ = Field.__implements__
-
- id = None
- default = ''
- title = 'Email Field'
- description = 'Email Field'
- validator = EmailValidator.EmailValidator()
+"""
+
+$Id$
+"""
+
+from Zope.App.Formulator.Field import Field
+from Zope.App.Formulator.Validators import EmailValidator
+
+
+class EmailField(Field):
+
+ __implements__ = Field.__implements__
+
+ id = None
+ default = ''
+ title = 'Email Field'
+ description = 'Email Field'
+ validator = EmailValidator.EmailValidator()
=== Zope3/lib/python/Zope/App/Formulator/Fields/Generic/FileField.py 1.1.4.1 => 1.1.4.2 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-from Zope.App.Formulator.Field import Field
-from Zope.App.Formulator.Validators import FileValidator
-
-
-class FileField(Field):
-
- __implements__ = Field.__implements__
-
- id = None
- default = ''
- title = 'File Field'
- description = 'File Field'
- validator = FileValidator.FileValidator()
+"""
+
+$Id$
+"""
+
+from Zope.App.Formulator.Field import Field
+from Zope.App.Formulator.Validators import FileValidator
+
+
+class FileField(Field):
+
+ __implements__ = Field.__implements__
+
+ id = None
+ default = ''
+ title = 'File Field'
+ description = 'File Field'
+ validator = FileValidator.FileValidator()
=== Zope3/lib/python/Zope/App/Formulator/Fields/Generic/FloatField.py 1.1.4.1 => 1.1.4.2 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-from Zope.App.Formulator.Field import Field
-from Zope.App.Formulator.Validators import FloatValidator
-
-
-class FloatField(Field):
-
- __implements__ = Field.__implements__
-
- id = None
- default = ''
- title = 'Float Field'
- description = 'Float Field'
- validator = FloatValidator.FloatValidator()
+"""
+
+$Id$
+"""
+
+from Zope.App.Formulator.Field import Field
+from Zope.App.Formulator.Validators import FloatValidator
+
+
+class FloatField(Field):
+
+ __implements__ = Field.__implements__
+
+ id = None
+ default = ''
+ title = 'Float Field'
+ description = 'Float Field'
+ validator = FloatValidator.FloatValidator()
=== Zope3/lib/python/Zope/App/Formulator/Fields/Generic/IntegerField.py 1.1.4.1 => 1.1.4.2 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-from Zope.App.Formulator.Field import Field
-from Zope.App.Formulator.Validators import IntegerValidator
-
-
-class IntegerField(Field):
-
- __implements__ = Field.__implements__
-
- id = None
- default = ''
- title = 'Integer Field'
- description = 'Integer Field'
- validator = IntegerValidator.IntegerValidator()
+"""
+
+$Id$
+"""
+
+from Zope.App.Formulator.Field import Field
+from Zope.App.Formulator.Validators import IntegerValidator
+
+
+class IntegerField(Field):
+
+ __implements__ = Field.__implements__
+
+ id = None
+ default = ''
+ title = 'Integer Field'
+ description = 'Integer Field'
+ validator = IntegerValidator.IntegerValidator()
=== Zope3/lib/python/Zope/App/Formulator/Fields/Generic/LinkField.py 1.1.4.1 => 1.1.4.2 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-from Zope.App.Formulator.Fields.Field import Field
-from Zope.App.Formulator.Validators import LinkValidator
-
-
-class LinkField(Field):
-
- __implements__ = Field.__implements__
-
- id = None
- default = ''
- title = 'Link Field'
- description = 'Link Field'
- validator = LinkValidator.LinkValidator()
+"""
+
+$Id$
+"""
+
+from Zope.App.Formulator.Fields.Field import Field
+from Zope.App.Formulator.Validators import LinkValidator
+
+
+class LinkField(Field):
+
+ __implements__ = Field.__implements__
+
+ id = None
+ default = ''
+ title = 'Link Field'
+ description = 'Link Field'
+ validator = LinkValidator.LinkValidator()
=== Zope3/lib/python/Zope/App/Formulator/Fields/Generic/ListField.py 1.1.4.1 => 1.1.4.2 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-from Zope.App.Formulator.Field import Field
-from Zope.App.Formulator.Validators import SelectionValidator
-
-
-class ListField(Field):
-
- __implements__ = Field.__implements__
-
- id = None
- default = ''
- title = 'List Field'
- description = 'List Field'
- validator = SelectionValidator.SelectionValidator()
+"""
+
+$Id$
+"""
+
+from Zope.App.Formulator.Field import Field
+from Zope.App.Formulator.Validators import SelectionValidator
+
+
+class ListField(Field):
+
+ __implements__ = Field.__implements__
+
+ id = None
+ default = ''
+ title = 'List Field'
+ description = 'List Field'
+ validator = SelectionValidator.SelectionValidator()
=== Zope3/lib/python/Zope/App/Formulator/Fields/Generic/PasswordField.py 1.1.4.1 => 1.1.4.2 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-from Zope.App.Formulator.Field import Field
-from Zope.App.Formulator.Validators import StringValidator
-
-
-class PasswordField(Field):
-
- __implements__ = Field.__implements__
-
- id = None
- default = ''
- title = 'Password Field'
- description = 'Password Field'
- validator = StringValidator.StringValidator()
+"""
+
+$Id$
+"""
+
+from Zope.App.Formulator.Field import Field
+from Zope.App.Formulator.Validators import StringValidator
+
+
+class PasswordField(Field):
+
+ __implements__ = Field.__implements__
+
+ id = None
+ default = ''
+ title = 'Password Field'
+ description = 'Password Field'
+ validator = StringValidator.StringValidator()
=== Zope3/lib/python/Zope/App/Formulator/Fields/Generic/PatternField.py 1.1.4.1 => 1.1.4.2 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-from Zope.App.Formulator.Field import Field
-from Zope.App.Formulator.Validators import PatternValidator
-
-
-class PatternField(Field):
-
- __implements__ = Field.__implements__
-
- id = None
- default = ''
- title = 'Pattern Field'
- description = 'Pattern Field'
- validator = PatternValidator.PatternValidator()
+"""
+
+$Id$
+"""
+
+from Zope.App.Formulator.Field import Field
+from Zope.App.Formulator.Validators import PatternValidator
+
+
+class PatternField(Field):
+
+ __implements__ = Field.__implements__
+
+ id = None
+ default = ''
+ title = 'Pattern Field'
+ description = 'Pattern Field'
+ validator = PatternValidator.PatternValidator()
=== Zope3/lib/python/Zope/App/Formulator/Fields/Generic/StringField.py 1.1.4.1 => 1.1.4.2 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-from Zope.App.Formulator.Field import Field
-from Zope.App.Formulator.Validators import StringValidator
-
-
-class StringField(Field):
-
- __implements__ = Field.__implements__
-
- id = None
- default = ''
- title = 'String Field'
- description = 'String Field'
- validator = StringValidator.StringValidator()
+"""
+
+$Id$
+"""
+
+from Zope.App.Formulator.Field import Field
+from Zope.App.Formulator.Validators import StringValidator
+
+
+class StringField(Field):
+
+ __implements__ = Field.__implements__
+
+ id = None
+ default = ''
+ title = 'String Field'
+ description = 'String Field'
+ validator = StringValidator.StringValidator()