[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Formulator/Fields/Generic - CheckBoxField.py:1.1.2.1 DateTimeField.py:1.1.2.1 EmailField.py:1.1.2.1 FileField.py:1.1.2.1 FileField.pyc:1.1.2.1 FloatField.py:1.1.2.1 IntegerField.py:1.1.2.1 LinesField.py:1.1.2.1 LinkField.py:1.1.2.1 ListField.py:1.1.2.1 ListTextAreaField.py:1.1.2.1 MethodField.py:1.1.2.1 MultiCheckBoxField.py:1.1.2.1 MultiListField.py:1.1.2.1 PasswordField.py:1.1.2.1 PatternField.py:1.1.2.1 RadioField.py:1.1.2.1 RawTextAreaField.py:1.1.2.1 StringField.py:1.1.2.1 StringField.pyc:1.1.2.1 TALESField.py:1.1.2.1 TextAreaField.py:1.1.2.1 __init__.py:1.1.2.1 __init__.pyc:1.1.2.1

Stephan Richter srichter@cbu.edu
Fri, 25 Jan 2002 09:11:12 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/Formulator/Fields/Generic
In directory cvs.zope.org:/tmp/cvs-serv20682/Formulator/Fields/Generic

Added Files:
      Tag: Zope-3x-branch
	CheckBoxField.py DateTimeField.py EmailField.py FileField.py 
	FileField.pyc FloatField.py IntegerField.py LinesField.py 
	LinkField.py ListField.py ListTextAreaField.py MethodField.py 
	MultiCheckBoxField.py MultiListField.py PasswordField.py 
	PatternField.py RadioField.py RawTextAreaField.py 
	StringField.py StringField.pyc TALESField.py TextAreaField.py 
	__init__.py __init__.pyc 
Log Message:
- Initial check-in of the Formulator code
- Even though not everything works (specifically the widgets are in bad 
  shape), I am checking that stuff in, so that Jim, Martijn F. and I can
  better work together.
- The FileEdit screen (which will be checked in in a minute) uses already
  formulator.
- The validators are closed to finished.
- I think we have to rethink some of the design, simply because it is too
  hard right now to create a field and a view for a property, even though
  I provided already some handy methods. However Formulator does not 
  depend on Property-driven content objects.
- Please contact me (srichter@cbu.edu) or the Zope3 mailining list to 
  discuss issues and design.


=== Added File Zope3/lib/python/Zope/App/Formulator/Fields/Generic/CheckBoxField.py ===
##############################################################################
#
# Copyright (c) 2001 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.
# 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
# 
##############################################################################
"""

Revision information: $Id: CheckBoxField.py,v 1.1.2.1 2002/01/25 14:11:07 srichter Exp $
"""

from Zope.App.Formulator.Fields.Field import Field
from Zope.App.Formulator.Validators import BooleanValidator


class CheckBoxField(Field):

    __implements__ = Field.__implements__

    id = None
    default = ''
    title = 'CheckBox Field'
    description = 'CheckBox Field'
    validator = BooleanValidator.BooleanValidator()


=== Added File Zope3/lib/python/Zope/App/Formulator/Fields/Generic/DateTimeField.py ===
##############################################################################
#
# Copyright (c) 2001 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.
# 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
# 
##############################################################################
"""

Revision information: $Id: DateTimeField.py,v 1.1.2.1 2002/01/25 14:11:07 srichter Exp $
"""

from Zope.App.Formulator.Fields.Field import Field
from Zope.App.Formulator.Validators import LinkValidator 
from DateTime import DateTime


class DateTimeField(Field):

    __implements__ = Field.__implements__

    id = None
    default = ''
    title = 'DateTime Field'
    description = 'DateTime Field'
    validator = Validator.DateTimeValidator()

    def __init__(self, id, **kw):

        apply(Field.__init__, (self, id), kw)

        if self.get_value('input_style') == 'text':
            self.sub_form = create_datetime_text_sub_form()
        elif value == 'list':
            self.sub_form = create_datetime_list_sub_form()
        else:
            assert 0, "Unknown input_style"
            
    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 = DateTime().year()
        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


=== Added File Zope3/lib/python/Zope/App/Formulator/Fields/Generic/EmailField.py ===
##############################################################################
#
# Copyright (c) 2001 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.
# 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
# 
##############################################################################
"""

Revision information: $Id: EmailField.py,v 1.1.2.1 2002/01/25 14:11:07 srichter Exp $
"""

from Zope.App.Formulator.Fields.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 = StringValidator.EmailValidator()


=== Added File Zope3/lib/python/Zope/App/Formulator/Fields/Generic/FileField.py ===
##############################################################################
#
# Copyright (c) 2001 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.
# 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
# 
##############################################################################
"""

Revision information: $Id: FileField.py,v 1.1.2.1 2002/01/25 14:11:07 srichter Exp $
"""

from Zope.App.Formulator.Fields.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()


=== Added File Zope3/lib/python/Zope/App/Formulator/Fields/Generic/FileField.pyc ===
-í
1Q<c       sI     d  Z    d k l Z  d k l Z  d e f d „  ƒ  YZ d S(   s   

Revision information: $Id: FileField.pyc,v 1.1.2.1 2002/01/25 14:11:07 srichter Exp $
(   s   Field(   s
   FileValidators	   FileFieldc      sD     e  i Z  e Z  d Z  d Z  d Z  e i ƒ  Z RS(   Ns    s
   File Field(	   s   Fields   __implements__s   Nones   ids   defaults   titles   descriptions
   FileValidators	   validator(    (    (    sE   /opt/Zope3/lib/python/Zope/App/Formulator/Fields/Generic/FileField.pys	   FileField s   				N(   s   __doc__s    Zope.App.Formulator.Fields.Fields   Fields   Zope.App.Formulator.Validatorss
   FileValidators	   FileField(   s   Fields	   FileFields
   FileValidator(    (    sE   /opt/Zope3/lib/python/Zope/App/Formulator/Fields/Generic/FileField.pys   ? s   

=== Added File Zope3/lib/python/Zope/App/Formulator/Fields/Generic/FloatField.py ===
##############################################################################
#
# Copyright (c) 2001 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.
# 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
# 
##############################################################################
"""

Revision information: $Id: FloatField.py,v 1.1.2.1 2002/01/25 14:11:07 srichter Exp $
"""

from Zope.App.Formulator.Fields.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()


=== Added File Zope3/lib/python/Zope/App/Formulator/Fields/Generic/IntegerField.py ===
##############################################################################
#
# Copyright (c) 2001 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.
# 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
# 
##############################################################################
"""

Revision information: $Id: IntegerField.py,v 1.1.2.1 2002/01/25 14:11:07 srichter Exp $
"""

from Zope.App.Formulator.Fields.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()


=== Added File Zope3/lib/python/Zope/App/Formulator/Fields/Generic/LinesField.py ===
##############################################################################
#
# Copyright (c) 2001 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.
# 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
# 
##############################################################################
"""

Revision information: $Id: LinesField.py,v 1.1.2.1 2002/01/25 14:11:07 srichter Exp $
"""

from Zope.App.Formulator.Fields.Field import Field
from Zope.App.Formulator.Validators import LinesValidator


class LinesField(Field):

    __implements__ = Field.__implements__

    id = None
    default = ''
    title = 'Lines Field'
    description = 'Lines Field'
    validator = LinesValidator.LinesValidator()


=== Added File Zope3/lib/python/Zope/App/Formulator/Fields/Generic/LinkField.py ===
##############################################################################
#
# Copyright (c) 2001 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.
# 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
# 
##############################################################################
"""

Revision information: $Id: LinkField.py,v 1.1.2.1 2002/01/25 14:11:07 srichter Exp $
"""

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()


=== Added File Zope3/lib/python/Zope/App/Formulator/Fields/Generic/ListField.py ===
##############################################################################
#
# Copyright (c) 2001 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.
# 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
# 
##############################################################################
"""

Revision information: $Id: ListField.py,v 1.1.2.1 2002/01/25 14:11:07 srichter Exp $
"""

from Zope.App.Formulator.Fields.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()


=== Added File Zope3/lib/python/Zope/App/Formulator/Fields/Generic/ListTextAreaField.py ===
##############################################################################
#
# Copyright (c) 2001 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.
# 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
# 
##############################################################################
"""

Revision information: $Id: ListTextAreaField.py,v 1.1.2.1 2002/01/25 14:11:07 srichter Exp $
"""

from Zope.App.Formulator.Fields.Field import Field
from Zope.App.Formulator.Validators import ListLinesValidator


class ListTextAreaField(Field):

    __implements__ = Field.__implements__

    id = None
    default = ''
    title = 'List Lines Field'
    description = 'List Lines Field'
    validator = ListLinesValidator.ListLinesValidator()
    


=== Added File Zope3/lib/python/Zope/App/Formulator/Fields/Generic/MethodField.py ===
import string
from DummyField import fields
import Widget, Validator
from Globals import Persistent
import Acquisition
from Field import ZMIField
from AccessControl import getSecurityManager

class MethodWidget(Widget.TextWidget):
    default = fields.MethodField('default',
                                 title='Default',
                                 default="",
                                 required=0)
    
    def render(self, field, key, value, REQUEST):
        if value == None:
            method_name = field.get_value('default')
        else:
            if value != "":
                method_name = value.method_name
            else:
                method_name = ""
        return Widget.TextWidget.render(self, field, key, method_name, REQUEST)

MethodWidgetInstance = MethodWidget()

class Method(Persistent, Acquisition.Implicit):
    """A method object; calls method name in acquisition context.
    """
    def __init__(self, method_name):
        self.method_name = method_name
        
    def __call__(self, *arg, **kw):
        # get method from acquisition path
        method = getattr(self, self.method_name)
        # check if we have 'View' permission for this method
        # (raises error if not)
        getSecurityManager().checkPermission('View', method)
        # okay, execute it with supplied arguments
        return apply(method, arg, kw)

class BoundMethod(Method):
    """A bound method calls a method on a particular object.
    Should be used internally only.
    """
    def __init__(self, object, method_name):
        BoundMethod.inheritedAttribute('__init__')(self, method_name)
        self.object = object
          
    def __call__(self, *arg, **kw):
        method = getattr(self.object, self.method_name)
        return apply(method, arg, kw)
    
class MethodValidator(Validator.StringBaseValidator):

    def validate(self, field, key, REQUEST):
        value = Validator.StringBaseValidator.validate(self, field, key,
                                                       REQUEST)

        if value == "" and not field.get_value('required'):
            return value

        return Method(value)
    
MethodValidatorInstance = MethodValidator()

class MethodField(ZMIField):
    meta_type = 'MethodField'

    internal_field = 1

    widget = MethodWidgetInstance
    validator = MethodValidatorInstance
    
    


=== Added File Zope3/lib/python/Zope/App/Formulator/Fields/Generic/MultiCheckBoxField.py ===
##############################################################################
#
# Copyright (c) 2001 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.
# 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
# 
##############################################################################
"""

Revision information: $Id: MultiCheckBoxField.py,v 1.1.2.1 2002/01/25 14:11:07 srichter Exp $
"""

from Zope.App.Formulator.Fields.Field import Field
from Zope.App.Formulator.Validator import MultiSelectionValidator


class MultiCheckBoxField(Field):

    __implements__ = Field.__implements__

    id = None
    default = ''
    title = 'Multi-CheckBox Field'
    description = 'Multi-CheckBox Field'
    validator = MultiSelectionValidator.MultiSelectionValidator()


=== Added File Zope3/lib/python/Zope/App/Formulator/Fields/Generic/MultiListField.py ===
##############################################################################
#
# Copyright (c) 2001 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.
# 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
# 
##############################################################################
"""

Revision information: $Id: MultiListField.py,v 1.1.2.1 2002/01/25 14:11:07 srichter Exp $
"""

from Zope.App.Formulator.Fields.Field import Field
from Zope.App.Formulator.Validator import MultiSelectionValidator


class MultiListField(Field):

    __implements__ = Field.__implements__

    id = None
    default = ''
    title = 'Multi-List Field'
    description = 'Multi-List Field'
    validator = MultiSelectionValidator.MultiSelectionValidator()


=== Added File Zope3/lib/python/Zope/App/Formulator/Fields/Generic/PasswordField.py ===
##############################################################################
#
# Copyright (c) 2001 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.
# 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
# 
##############################################################################
"""

Revision information: $Id: PasswordField.py,v 1.1.2.1 2002/01/25 14:11:07 srichter Exp $
"""

from Zope.App.Formulator.Fields.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()


=== Added File Zope3/lib/python/Zope/App/Formulator/Fields/Generic/PatternField.py ===
##############################################################################
#
# Copyright (c) 2001 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.
# 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
# 
##############################################################################
"""

Revision information: $Id: PatternField.py,v 1.1.2.1 2002/01/25 14:11:07 srichter Exp $
"""

from Zope.App.Formulator.Fields.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()


=== Added File Zope3/lib/python/Zope/App/Formulator/Fields/Generic/RadioField.py ===
##############################################################################
#
# Copyright (c) 2001 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.
# 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
# 
##############################################################################
"""

Revision information: $Id: RadioField.py,v 1.1.2.1 2002/01/25 14:11:07 srichter Exp $
"""

from Zope.App.Formulator.Fields.Field import Field
from Zope.App.Formulator.Validators import SelectionValidator


class RadioField(Field):

    __implements__ = Field.__implements__

    id = None
    default = ''
    title = 'Radio Field'
    description = 'Radio Field'
    validator = SelectionValidator.SelectionValidator()


=== Added File Zope3/lib/python/Zope/App/Formulator/Fields/Generic/RawTextAreaField.py ===
##############################################################################
#
# Copyright (c) 2001 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.
# 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
# 
##############################################################################
"""

Revision information: $Id: RawTextAreaField.py,v 1.1.2.1 2002/01/25 14:11:07 srichter Exp $
"""

from Zope.App.Formulator.Fields.Field import Field
from Zope.App.Formulator.Validators import StringValidator 


class RawTextAreaField(Field):

    __implements__ = Field.__implements__

    id = None
    default = ''
    title = 'Text Area Field'
    description = 'Simple Text Area Field'
    validator = StringValidator.StringValidator()


=== Added File Zope3/lib/python/Zope/App/Formulator/Fields/Generic/StringField.py ===
##############################################################################
#
# Copyright (c) 2001 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.
# 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
# 
##############################################################################
"""

Revision information: $Id: StringField.py,v 1.1.2.1 2002/01/25 14:11:07 srichter Exp $
"""

from Zope.App.Formulator.Fields.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()


=== Added File Zope3/lib/python/Zope/App/Formulator/Fields/Generic/StringField.pyc ===
-í
æQ<c       sI     d  Z    d k l Z  d k l Z  d e f d „  ƒ  YZ d S(   s   

Revision information: $Id: StringField.pyc,v 1.1.2.1 2002/01/25 14:11:07 srichter Exp $
(   s   Field(   s   StringValidators   StringFieldc      sD     e  i Z  e Z  d Z  d Z  d Z  e i ƒ  Z RS(   Ns    s   String Field(	   s   Fields   __implements__s   Nones   ids   defaults   titles   descriptions   StringValidators	   validator(    (    (    sG   /opt/Zope3/lib/python/Zope/App/Formulator/Fields/Generic/StringField.pys   StringField s   				N(   s   __doc__s    Zope.App.Formulator.Fields.Fields   Fields   Zope.App.Formulator.Validatorss   StringValidators   StringField(   s   StringValidators   Fields   StringField(    (    sG   /opt/Zope3/lib/python/Zope/App/Formulator/Fields/Generic/StringField.pys   ? s   

=== Added File Zope3/lib/python/Zope/App/Formulator/Fields/Generic/TALESField.py ===
import string
from DummyField import fields
import Widget, Validator
from Globals import Persistent
import Acquisition
from Field import ZMIField
from AccessControl import getSecurityManager
   
class TALESWidget(Widget.TextWidget):
    default = fields.MethodField('default',
                                 title='Default',
                                 default="",
                                 required=0)
    
    def render(self, field, key, value, REQUEST):
        if value == None:
            text = field.get_value('default')
        else:
            if value != "":
                text = value._text
            else:
                text = ""
        return Widget.TextWidget.render(self, field, key, text, REQUEST)

TALESWidgetInstance = TALESWidget()

class TALESNotAvailable(Exception):
    pass

try:
    # try to import getEngine from TALES
    from Products.PageTemplates.Expressions import getEngine
    
    class TALESMethod(Persistent, Acquisition.Implicit):
        """A method object; calls method name in acquisition context.
        """
        def __init__(self, text):
            self._text = text
            #self._expr = getEngine().compile(text)

        def __call__(self, **kw):
            expr = getEngine().compile(self._text)
            return getEngine().getContext(kw).evaluate(expr)

            # check if we have 'View' permission for this method
            # (raises error if not)
            # getSecurityManager().checkPermission('View', method)

    TALES_AVAILABLE = 1
    
except ImportError:
    # cannot import TALES, so supply dummy TALESMethod
    class TALESMethod(Persistent, Acquisition.Implicit):
        """A dummy method in case TALES is not available.
        """
        def __init__(self, text):
            self._text = text

        def __call__(self, **kw):
            raise TALESNotAvailable
    TALES_AVAILABLE = 0
    
class TALESValidator(Validator.StringBaseValidator):

    def validate(self, field, key, REQUEST):
        value = Validator.StringBaseValidator.validate(self, field, key,
                                                       REQUEST)

        if value == "" and not field.get_value('required'):
            return value

        return TALESMethod(value)
    
TALESValidatorInstance = TALESValidator()

class TALESField(ZMIField):
    meta_type = 'TALESField'

    internal_field = 1

    widget = TALESWidgetInstance
    validator = TALESValidatorInstance
    
    


=== Added File Zope3/lib/python/Zope/App/Formulator/Fields/Generic/TextAreaField.py ===
##############################################################################
#
# Copyright (c) 2001 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.
# 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
# 
##############################################################################
"""

Revision information: $Id: TextAreaField.py,v 1.1.2.1 2002/01/25 14:11:07 srichter Exp $
"""

from Zope.App.Formulator.Fields.Field import Field
from Zope.App.Formulator.Validators import TextValidator 


class TextAreaField(Field):

    __implements__ = Field.__implements__

    id = None
    default = ''
    title = 'Text Area Field'
    description = 'Text Area Field'
    validator = TextValidator.TextValidator()


=== Added File Zope3/lib/python/Zope/App/Formulator/Fields/Generic/__init__.py ===
##############################################################################
#
# Copyright (c) 2001 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.
# 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
# 
##############################################################################
"""

Revision information: $Id: __init__.py,v 1.1.2.1 2002/01/25 14:11:07 srichter Exp $
"""


=== Added File Zope3/lib/python/Zope/App/Formulator/Fields/Generic/__init__.pyc ===
-í
Ã^Q<c       s     d  Z   d S(   s   

Revision information: $Id: __init__.pyc,v 1.1.2.1 2002/01/25 14:11:07 srichter Exp $
N(   s   __doc__(    (    (    sD   /opt/Zope3/lib/python/Zope/App/Formulator/Fields/Generic/__init__.pys   ? s