Beispiel #1
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 #3
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 #4
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())
Beispiel #5
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 #6
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)