Beispiel #1
0
 def test_signature(self):
   for field in FieldRegistry.get_field_classes().itervalues():
     self.assertEquals(('self', 'value', 'REQUEST', 'render_prefix'),
                       field.render_view.im_func.func_code.co_varnames)
     if field is not ProxyField.ProxyField:
       self.assertEquals(('self', 'field', 'value', 'REQUEST'),
         field.widget.render_view.im_func.func_code.co_varnames[:4], '%s %s' % (field.widget, field.widget.render_view.im_func.func_code.co_varnames[:4]))
Beispiel #2
0
 def test_signature(self):
   for field in FieldRegistry.get_field_classes().itervalues():
     self.assertEqual(('self', 'value', 'REQUEST', 'render_prefix'),
                       field.render_view.im_func.func_code.co_varnames)
     if field is not ProxyField.ProxyField:
       self.assertEqual(('self', 'field', 'value', 'REQUEST'),
         field.widget.render_view.im_func.func_code.co_varnames[:4], '%s %s' % (field.widget, field.widget.render_view.im_func.func_code.co_varnames[:4]))
Beispiel #3
0
 def test_signature(self):
     for field in FieldRegistry.get_field_classes().itervalues():
         self.assertEqual(
             ("self", "value", "REQUEST", "render_prefix"), field.render_view.im_func.func_code.co_varnames
         )
         if field is not ProxyField.ProxyField:
             self.assertEqual(
                 ("self", "field", "value", "REQUEST"),
                 field.widget.render_view.im_func.func_code.co_varnames[:4],
                 "%s %s" % (field.widget, field.widget.render_view.im_func.func_code.co_varnames[:4]),
             )
Beispiel #4
0
 def manage_addField(self, id, title, fieldname, REQUEST=None, **options):
     """Add a new field to the form.
     id        -- the id of the field to add
     title     -- the title of the field to add; this will be used in
                  displays of the field on forms
     fieldname -- the name of the field (meta_type) to add
     Result    -- empty string
     """
     title = string.strip(title)
     if not title:
         title = id # title is always required, use id if not provided
     if self.get_unicode_mode():
         # ZMI input is UTF-8 always (?)
         title = ensure_unicode(title)
     # get the field class we want to add
     field_class = FieldRegistry.get_field_class(fieldname)
     # create field instance
     field = field_class(id, title=title, **options)
     # add the field to the form
     id = self._setObject(id, field)
     # respond to add_and_edit button if necessary
     add_and_edit(self, id, REQUEST)
     return ''
def listFields():
    mapping = FieldRegistry.get_field_classes()
    field_types = mapping.keys()
    field_types.sort()
    return field_types
def getFieldFactory(fieldname):
    return FieldRegistry.get_field_class(fieldname)
Beispiel #7
0
def initialize(context):
    import Document
    initializeProduct(context,
                      this_module,
                      globals(),
                      document_module=Document,
                      document_classes=document_classes,
                      object_classes=object_classes,
                      portal_tools=portal_tools,
                      content_constructors=content_constructors,
                      content_classes=content_classes)

    # Initialise ERP5Form Formulator
    FieldRegistry.registerField(ProxyField.ProxyField, 'www/StringField.gif')
    FieldRegistry.registerField(DurationField.DurationField,
                                'www/StringField.gif')
    FieldRegistry.registerField(EditorField.EditorField,
                                'www/TextAreaField.gif')
    FieldRegistry.registerField(FormBox.FormBox, 'www/StringField.gif')
    FieldRegistry.registerField(POSBox.POSBox, 'www/StringField.gif')
    FieldRegistry.registerField(ListBox.ListBox, 'www/StringField.gif')
    FieldRegistry.registerField(ReportBox.ReportBox, 'www/StringField.gif')
    FieldRegistry.registerField(PlanningBox.PlanningBox, 'www/StringField.gif')
    FieldRegistry.registerField(MatrixBox.MatrixBox, 'www/StringField.gif')
    FieldRegistry.registerField(RelationField.RelationStringField,
                                'www/StringField.gif')
    FieldRegistry.registerField(MultiRelationField.MultiRelationStringField,
                                'www/StringField.gif')
    FieldRegistry.registerField(ImageField.ImageField, 'www/StringField.gif')
    FieldRegistry.registerField(StandardFields.StringField,
                                'www/StringField.gif')
    FieldRegistry.registerField(StandardFields.CheckBoxField,
                                'www/CheckBoxField.gif')
    FieldRegistry.registerField(StandardFields.IntegerField,
                                'www/IntegerField.gif')
    FieldRegistry.registerField(StandardFields.TextAreaField,
                                'www/TextAreaField.gif')
    FieldRegistry.registerField(StandardFields.RawTextAreaField,
                                'www/TextAreaField.gif')
    FieldRegistry.registerField(StandardFields.LinesField,
                                'www/LinesField.gif')
    FieldRegistry.registerField(StandardFields.ListField, 'www/ListField.gif')
    FieldRegistry.registerField(StandardFields.MultiListField,
                                'www/MultiListField.gif')
    FieldRegistry.registerField(ParallelListField.ParallelListField,
                                'www/MultiListField.gif')
    FieldRegistry.registerField(StandardFields.RadioField,
                                'www/RadioField.gif')
    FieldRegistry.registerField(StandardFields.MultiCheckBoxField,
                                'www/MultiCheckBoxField.gif')
    FieldRegistry.registerField(StandardFields.PasswordField,
                                'www/PasswordField.gif')
    FieldRegistry.registerField(StandardFields.EmailField,
                                'www/EmailField.gif')
    FieldRegistry.registerField(StandardFields.PatternField,
                                'www/PatternField.gif')
    FieldRegistry.registerField(StandardFields.FloatField,
                                'www/FloatField.gif')
    FieldRegistry.registerField(StandardFields.DateTimeField,
                                'www/DateTimeField.gif')
    FieldRegistry.registerField(StandardFields.FileField, 'www/FileField.gif')
    FieldRegistry.registerField(StandardFields.LinkField, 'www/LinkField.gif')
    FieldRegistry.registerField(StandardFields.LabelField,
                                'www/LabelField.gif')
    FieldRegistry.registerField(MultiLinkField.MultiLinkField,
                                'www/LinkField.gif')
    FieldRegistry.registerField(InputButtonField.InputButtonField,
                                'www/StringField.gif')
    FieldRegistry.registerField(OOoChart.OOoChart, 'www/StringField.gif')
    FieldRegistry.registerField(CaptchaField.CaptchaField,
                                'www/StringField.gif')

    # some helper fields
    FieldRegistry.registerField(HelperFields.ListTextAreaField)
    FieldRegistry.registerField(HelperFields.MethodField)
    FieldRegistry.registerField(HelperFields.TALESField)

    import HyperLinkField
    FieldRegistry.registerField(HyperLinkField.HyperLinkField,
                                'www/LinkField.gif')

    import VideoField
    FieldRegistry.registerField(VideoField.VideoField, 'www/StringField.gif')
    import AudioField
    FieldRegistry.registerField(AudioField.AudioField, 'www/StringField.gif')
    import GadgetField
    FieldRegistry.registerField(GadgetField.GadgetField, 'www/StringField.gif')

    # register help for the product
    context.registerHelp()
    # register field help for all fields
    FieldRegistry.registerFieldHelp(context)

    # make Dummy Fields into real fields
    FieldRegistry.initializeFields()

    # do initialization of Form class to make fields addable
    Form.initializeForm(FieldRegistry)
    Form.initializeForm(FieldRegistry, form_class=Report.ERP5Report)

    # Register FSPDFTemplate icon
    registerIcon(PDFTemplate.FSPDFTemplate, 'www/PDF.png', globals())
    # Register ProxyField icon
    registerIcon(ProxyField.ProxyField, 'www/ProxyField.png', globals())
    """Formulator reference field.
    """
    meta_type = "ReferenceField"
    widget = ReferenceWidget()
    validator = ReferenceValidator()

    def get_interface(self):
        try:
            interface = self.get_value('interface')
        except KeyError:
            interface = ISilvaObject
        return interface.__identifier__


# This get initialized by Grok and register the formulator widget
FieldRegistry.registerField(ReferenceField, 'www/BasicField.gif')


class ReferenceValueWriter(FieldValueWriter):
    component.adapts(ReferenceField, Interface)

    def __init__(self, *args):
        super(ReferenceValueWriter, self).__init__(*args)
        self.context = self.form.context

    def delete(self):
        if self.identifier in self.content.__dict__:
            identifier = self.content.__dict__[self.identifier]
            references = ReferenceSet(self.context, identifier)
            references.set([])
            del self.content.__dict__[self.identifier]
Beispiel #9
0
def initialize(context):
    """Initialize the Formulator product.
    """
    # register field classes
    FieldRegistry.registerField(StandardFields.StringField,
                                'www/StringField.gif')
    FieldRegistry.registerField(StandardFields.CheckBoxField,
                                'www/CheckBoxField.gif')
    FieldRegistry.registerField(StandardFields.IntegerField,
                                'www/IntegerField.gif')
    FieldRegistry.registerField(StandardFields.TextAreaField,
                                'www/TextAreaField.gif')
    FieldRegistry.registerField(StandardFields.RawTextAreaField,
                                'www/TextAreaField.gif')
    FieldRegistry.registerField(StandardFields.LinesField,
                                'www/LinesField.gif')
    FieldRegistry.registerField(StandardFields.ListField, 'www/ListField.gif')
    FieldRegistry.registerField(StandardFields.MultiListField,
                                'www/MultiListField.gif')
    FieldRegistry.registerField(StandardFields.RadioField,
                                'www/RadioField.gif')
    FieldRegistry.registerField(StandardFields.MultiCheckBoxField,
                                'www/MultiCheckBoxField.gif')
    FieldRegistry.registerField(StandardFields.PasswordField,
                                'www/PasswordField.gif')
    FieldRegistry.registerField(StandardFields.EmailField,
                                'www/EmailField.gif')
    FieldRegistry.registerField(StandardFields.PatternField,
                                'www/PatternField.gif')
    FieldRegistry.registerField(StandardFields.FloatField,
                                'www/FloatField.gif')
    FieldRegistry.registerField(StandardFields.DateTimeField,
                                'www/DateTimeField.gif')
    FieldRegistry.registerField(StandardFields.FileField, 'www/FileField.gif')
    FieldRegistry.registerField(StandardFields.LinkField, 'www/LinkField.gif')
    FieldRegistry.registerField(StandardFields.LabelField,
                                'www/LabelField.gif')

    # some helper fields
    FieldRegistry.registerField(HelperFields.ListTextAreaField)
    FieldRegistry.registerField(HelperFields.MethodField)
    FieldRegistry.registerField(HelperFields.TALESField)

    # some other fields
    FieldRegistry.registerField(EmailLinesField.EmailLinesField,
                                'www/EmailField.gif')
    FieldRegistry.registerField(InterfaceField.InterfaceField,
                                'www/BasicField.gif')

    # obsolete field (same as helper; useable but not addable)
    FieldRegistry.registerField(StandardFields.RangedIntegerField,
                                'www/RangedIntegerField.gif')

    # register the form itself
    context.registerClass(Form.ZMIForm,
                          constructors=(Form.manage_addForm, Form.manage_add),
                          icon='www/Form.gif')

    # make Dummy Fields into real fields
    FieldRegistry.initializeFields()

    # do initialization of Form class to make fields addable
    Form.initializeForm(FieldRegistry)

    # register help for the product
    context.registerHelp()
Beispiel #10
0
 def get_real_field(self):
     """Get an actual field for this property.
     """
     return apply(FieldRegistry.get_field_class(self.desired_meta_class),
                  (self.id, ), self.kw)
 def get_real_field(self):
     """Get an actual field for this property.
     """
     return apply(FieldRegistry.get_field_class(self.desired_meta_class),
                  (self.id,), self.kw)
Beispiel #12
0
def initialize( context ):
    import Document
    initializeProduct(context, this_module, globals(),
                         document_module = Document,
                         document_classes = document_classes,
                         object_classes = object_classes,
                         portal_tools = portal_tools,
                         content_constructors = content_constructors,
                         content_classes = content_classes)

    # Initialise ERP5Form Formulator
    FieldRegistry.registerField(ProxyField.ProxyField,
                                'www/StringField.gif')
    FieldRegistry.registerField(DurationField.DurationField,
                                'www/StringField.gif')
    FieldRegistry.registerField(EditorField.EditorField,
                                'www/TextAreaField.gif')
    FieldRegistry.registerField(FormBox.FormBox,
                                'www/StringField.gif')
    FieldRegistry.registerField(POSBox.POSBox,
                                'www/StringField.gif')
    FieldRegistry.registerField(ListBox.ListBox,
                                'www/StringField.gif')
    FieldRegistry.registerField(ReportBox.ReportBox,
                                'www/StringField.gif')
    FieldRegistry.registerField(PlanningBox.PlanningBox,
                                'www/StringField.gif')
    FieldRegistry.registerField(MatrixBox.MatrixBox,
                                'www/StringField.gif')
    FieldRegistry.registerField(RelationField.RelationStringField,
                                'www/StringField.gif')
    FieldRegistry.registerField(MultiRelationField.MultiRelationStringField,
                                'www/StringField.gif')
    FieldRegistry.registerField(ImageField.ImageField,
                                'www/StringField.gif')
    FieldRegistry.registerField(StandardFields.StringField,
                                'www/StringField.gif')
    FieldRegistry.registerField(StandardFields.CheckBoxField,
                                'www/CheckBoxField.gif')
    FieldRegistry.registerField(StandardFields.IntegerField,
                                'www/IntegerField.gif')
    FieldRegistry.registerField(StandardFields.TextAreaField,
                                'www/TextAreaField.gif')
    FieldRegistry.registerField(StandardFields.RawTextAreaField,
                                'www/TextAreaField.gif')
    FieldRegistry.registerField(StandardFields.LinesField,
                                'www/LinesField.gif')
    FieldRegistry.registerField(StandardFields.ListField,
                                'www/ListField.gif')
    FieldRegistry.registerField(StandardFields.MultiListField,
                                'www/MultiListField.gif')
    FieldRegistry.registerField(ParallelListField.ParallelListField,
                                'www/MultiListField.gif')
    FieldRegistry.registerField(StandardFields.RadioField,
                                'www/RadioField.gif')
    FieldRegistry.registerField(StandardFields.MultiCheckBoxField,
                                'www/MultiCheckBoxField.gif')
    FieldRegistry.registerField(StandardFields.PasswordField,
                                'www/PasswordField.gif')
    FieldRegistry.registerField(StandardFields.EmailField,
                                'www/EmailField.gif')
    FieldRegistry.registerField(StandardFields.PatternField,
                                'www/PatternField.gif')
    FieldRegistry.registerField(StandardFields.FloatField,
                                'www/FloatField.gif')
    FieldRegistry.registerField(StandardFields.DateTimeField,
                                'www/DateTimeField.gif')
    FieldRegistry.registerField(StandardFields.FileField,
                                'www/FileField.gif')
    FieldRegistry.registerField(StandardFields.LinkField,
                                'www/LinkField.gif')
    FieldRegistry.registerField(StandardFields.LabelField,
                                'www/LabelField.gif')
    FieldRegistry.registerField(MultiLinkField.MultiLinkField,
                                'www/LinkField.gif')
    FieldRegistry.registerField(InputButtonField.InputButtonField,
                                'www/StringField.gif')
    FieldRegistry.registerField(OOoChart.OOoChart,
                                'www/StringField.gif')
    FieldRegistry.registerField(CaptchaField.CaptchaField,
                                'www/StringField.gif')

    # some helper fields
    FieldRegistry.registerField(HelperFields.ListTextAreaField)
    FieldRegistry.registerField(HelperFields.MethodField)
    FieldRegistry.registerField(HelperFields.TALESField)

    import HyperLinkField
    FieldRegistry.registerField(HyperLinkField.HyperLinkField,
                                'www/LinkField.gif')

    import VideoField
    FieldRegistry.registerField(VideoField.VideoField,
                                'www/StringField.gif')
    import AudioField
    FieldRegistry.registerField(AudioField.AudioField,
                                'www/StringField.gif')

    # register help for the product
    context.registerHelp()
    # register field help for all fields
    FieldRegistry.registerFieldHelp(context)

    # make Dummy Fields into real fields
    FieldRegistry.initializeFields()

    # do initialization of Form class to make fields addable
    Form.initializeForm(FieldRegistry)
    Form.initializeForm(FieldRegistry, form_class=Report.ERP5Report)

    # Register FSPDFTemplate icon
    registerIcon(PDFTemplate.FSPDFTemplate,
                        'www/PDF.png', globals())
    # Register ProxyField icon
    registerIcon(ProxyField.ProxyField,
                        'www/ProxyField.png', globals())
def listFields():
    mapping = FieldRegistry.get_field_classes()
    field_types = list(mapping.keys())
    field_types.sort()
    return field_types
def getFieldFactory(fieldname):
    return FieldRegistry.get_field_class(fieldname)
Beispiel #15
0
def initialize(context):
    """Initialize the Formulator product.
    """
    # register field classes
    FieldRegistry.registerField(StandardFields.StringField,
                                'www/StringField.gif')
    FieldRegistry.registerField(StandardFields.CheckBoxField,
                                'www/CheckBoxField.gif')
    FieldRegistry.registerField(StandardFields.IntegerField,
                                'www/IntegerField.gif')
    FieldRegistry.registerField(StandardFields.TextAreaField,
                                'www/TextAreaField.gif')
    FieldRegistry.registerField(StandardFields.RawTextAreaField,
                                'www/TextAreaField.gif')
    FieldRegistry.registerField(StandardFields.LinesField,
                                'www/LinesField.gif')
    FieldRegistry.registerField(StandardFields.ListField,
                                'www/ListField.gif')
    FieldRegistry.registerField(StandardFields.MultiListField,
                                'www/MultiListField.gif')
    FieldRegistry.registerField(StandardFields.RadioField,
                                'www/RadioField.gif')
    FieldRegistry.registerField(StandardFields.MultiCheckBoxField,
                                'www/MultiCheckBoxField.gif')
    FieldRegistry.registerField(StandardFields.PasswordField,
                                'www/PasswordField.gif')
    FieldRegistry.registerField(StandardFields.EmailField,
                                'www/EmailField.gif')
    FieldRegistry.registerField(StandardFields.PatternField,
                                'www/PatternField.gif')
    FieldRegistry.registerField(StandardFields.FloatField,
                                'www/FloatField.gif')
    FieldRegistry.registerField(StandardFields.DateTimeField,
                                'www/DateTimeField.gif')
    FieldRegistry.registerField(StandardFields.FileField,
                                'www/FileField.gif')
    FieldRegistry.registerField(StandardFields.LinkField,
                                'www/LinkField.gif')
    FieldRegistry.registerField(StandardFields.LabelField,
                                'www/LabelField.gif')

    # some helper fields
    FieldRegistry.registerField(HelperFields.ListTextAreaField)
    FieldRegistry.registerField(HelperFields.MethodField)
    FieldRegistry.registerField(HelperFields.TALESField)

    # some other fields
    FieldRegistry.registerField(
       EmailLinesField.EmailLinesField, 'www/EmailField.gif')
    FieldRegistry.registerField(
       InterfaceField.InterfaceField, 'www/BasicField.gif')

    # obsolete field (same as helper; useable but not addable)
    FieldRegistry.registerField(
       StandardFields.RangedIntegerField, 'www/RangedIntegerField.gif')

    # register the form itself
    context.registerClass(
        Form.ZMIForm,
        constructors = (Form.manage_addForm,
                        Form.manage_add),
        icon = 'www/Form.gif')

    # make Dummy Fields into real fields
    FieldRegistry.initializeFields()

    # do initialization of Form class to make fields addable
    Form.initializeForm(FieldRegistry)

    # register help for the product
    context.registerHelp()
Beispiel #16
0
# -*- coding: utf-8 -*-
# Copyright (c) 2008-2013 Infrae. All rights reserved.
# See also LICENSE.txt

from zope.component import getMultiAdapter
from AccessControl import ModuleSecurityInfo, allow_module
from Products.Formulator.FieldRegistry import FieldRegistry

from silva.captcha import formulator
from silva.captcha.field import Captcha

FieldRegistry.registerField(formulator.CaptchaField) # XXX fix icon

allow_module('silva.captcha')
module_security = ModuleSecurityInfo('silva.captcha')
module_security.declareProtected('View', 'validate')
def validate(context, request, input):
    """Validate a potential captcha entry for a Python Script.
    """
    captcha = getMultiAdapter((context, request), name='captcha')
    return captcha.verify(input)