コード例 #1
0

###
# we use these fields in several schemata

validatorOverrideField = \
        TALESString('fgTValidator',
            schemata='overrides',
            searchable=0,
            required=0,
            validators=('talesvalidator',),
            default="python:False",
            write_permission=EDIT_TALES_PERMISSION,
            widget=StringWidget(label=_(u'label_fgtvalidator_text', default=u"Custom Validator"),
                description=_(u'help_fgtvalidator_text', default=u"""
                    A TALES expression that will be evaluated when the form is validated.
                    Validate against 'value', which will contain the field input.
                    Return False if valid; if not valid return a string error message.
                    E.G., "python: test(value=='eggs', False, 'input must be eggs')" will
                    require "eggs" for input.
                    PLEASE NOTE: errors in the evaluation of this expression will cause
                    an error on form display.
                """),
                size=70,
                ),
            )

rowsField = \
    IntegerField('fgRows',
        searchable=0,
        required=0,
        default='5',
コード例 #2
0
                                     The form fields are available using the python string format e.g. {field-id} \
                                     Use {now} for the submission datetime.',
                   )),
 TALESString('formatScript',
     schemata='overrides',
     searchable=0,
     required=0,
     validators=('talesvalidator', ),
     write_permission=EDIT_TALES_PERMISSION,
     default='',
     isMetadata=True,
     languageIndependent=1,
     widget=atapi.StringWidget(label=_(u'label_BeforeAdapterOverride_text',
                                 default=u"Before Adapter Script"),
         description=_(u'help_BeforeAdapterOverride_text', default=\
             u"A TALES expression that will be called before this adapter runs. "
             "Form input will be in the request.form dictionary. "
             "Leave empty if unneeded. "
             "The most common use of this field is to call a python script "
             "to clean up form input. "
             "If the return value is None then the adapter will use request.form "
             "If the return value is a dictionary then the adapter will use the "
             "returned dictionary. "
             "PLEASE NOTE: errors in the evaluation of this expression will "
             "cause an error on form display."),
         size=70,
         ),
     ),
 DataGridField(
     name='field_map',
     widget=DataGridWidget(
コード例 #3
0
     ),
 ),
 TALESString(
     'onDisplayOverride',
     schemata='overrides',
     searchable=0,
     required=0,
     validators=('talesvalidator', ),
     write_permission=EDIT_TALES_PERMISSION,
     default='',
     languageIndependent=1,
     widget=StringWidget(
         label=_(u'label_OnDisplayOverride_text',
                 default=u"Form Setup Script"),
         description=_(u'help_OnDisplayOverride_text',
                       default=u"""
             A TALES expression that will be called when the form is
             displayed.
             Leave empty if unneeded.
             The most common use of this field is to call a python script
             that sets defaults for multiple fields by pre-populating
             request.form.
             Any value returned by the expression is ignored.
             PLEASE NOTE: errors in the evaluation of this expression
             will cause an error on form display.
         """),
         size=70,
     ),
 ),
 TALESString(
     'afterValidationOverride',
コード例 #4
0
    atapi.StringField('ct_interface',
                      schemata="default",
                      vocabulary_factory='eea.relations.voc.ObjectProvides',
                      validators=('eea.relations.contenttype', ),
                      widget=atapi.SelectionWidget(
                          label='Interface',
                          label_msgid='widget_interface_title',
                          description='Select interface',
                          description_msgid='widget_interface_description',
                          i18n_domain="eea")),
    TALESString(
        'ct_default_location',
        schemata="default",
        default="python:None",
        widget=atapi.StringWidget(
            label='Default location expression',
            label_msgid='widget_portal_type_title',
            description=('Enter a TALES expression that resolves the default '
                         'location for this content type'),
            description_msgid='widget_ct_default_location',
            i18n_domain="eea")),
))

EditSchema['description'].widget.modes = ()


class EEARelationsContentType(ATFolder):
    """ Relation node
    """
    implements(IContentType)
    portal_type = meta_type = 'EEARelationsContentType'
コード例 #5
0
         _(u'Select which action should be performed when the form containing this adapter is submitted.'
           ),
         format="radio",
     ),
 ),
 TALESString(
     'updateMatchExpression',
     schemata="create vs. update",
     required=False,
     searchable=False,
     default="",
     validators=('talesvalidator', ),
     read_permission=ModifyPortalContent,
     widget=StringWidget(
         label=_(u"Expression to match existing object for update"),
         description=
         _(u"Enter a TALES expression which evaluates to a SOQL WHERE clause that returns the "
           u"Salesforce.com object you want to update.  If you interpolate input from the request "
           u"into single quotes in the SOQL statement, be sure to escape it using the sanitize_soql "
           u"method. For example, python:\"Username__c='\" + sanitize_soql(request['username']) + \"'\""
           ),
         visible={
             'view': 'invisible',
             'edit': 'visible'
         },
     ),
 ),
 StringField(
     'actionIfNoExistingObject',
     schemata="create vs. update",
     required=True,
     searchable=False,
コード例 #6
0
class FGRichLabelField(BaseFormField):
    """ Rich-text label field """

    security  = ClassSecurityInfo()

    schema = BareFieldSchema.copy() + Schema((
        HtmlTextField('fgDefault',
            searchable=0,
            required=0,
            validators = ('isTidyHtmlWithCleanup',),
            default_content_type = 'text/html',
            default_output_type = 'text/x-html-safe',
            allowable_content_types = zconf.ATDocument.allowed_content_types,
            widget=TinyMCEWidget(label=_('label_fglabelbody_text', default='Label body'),
                description=_('help_fglabelbody_text', default="""
                    The text to display in the form.
                """),
                allow_file_upload = False,
                ),
            ),
        TALESString('fgTDefault',
            schemata='overrides',
            searchable=0,
            required=0,
            validators=('talesvalidator',),
            default='',
            write_permission=EDIT_TALES_PERMISSION,
            widget=StringWidget(label=_('label_fgtdefault_text', default="Default Expression"),
                description=_('help_fgtdefault_text', default="""
                    A TALES expression that will be evaluated when the form is displayed
                    to get the field default value.
                    Leave empty if unneeded. Your expression should evaluate as a string.
                    PLEASE NOTE: errors in the evaluation of this expression will cause
                    an error on form display.
                """),
                size=70,
                ),
            ),
        ))

    schema['title'].widget.label = _('label_title', default="Title")
    schema['title'].widget.description = _('help_notdisplayed_text', default="Not displayed on form.")
    schema['description'].widget.visible = {'view':'invisible','edit':'invisible'}

    # Standard content type setup
    portal_type = meta_type = 'FormRichLabelField'
    archetype_name = 'Rich Label Field'
    content_icon = 'RichLabelField.gif'
    typeDescription= 'A rich-text label'

    def __init__(self, oid, **kwargs):
        """ initialize class """

        BaseFormField.__init__(self, oid, **kwargs)

        # set a preconfigured field as an instance attribute
        self.fgField = HtmlTextField('fg_text_field',
            searchable=0,
            required=0,
            write_permission = View,
            default_content_type = 'text/html',
            default_output_type = 'text/x-html-safe',
            allowable_content_types = zconf.ATDocument.allowed_content_types,
            widget = RichLabelWidget(),
            )

    security.declareProtected(ModifyPortalContent, 'setFgDefault')
    def setFgDefault(self, value, **kw):
        """ set default for field """

        self.fgField.default = value

    def getRawFgDefault(self, **kw):
        """ get default for field """

        return self.fgField.default

    security.declareProtected(View, 'isBinary')
    def isBinary(self, key):
        return False;

    security.declareProtected(View, 'getContentType')
    def getContentType(self, key=None):
        return 'text/html'

    def isLabel(self):
        return True
コード例 #7
0
        ),
    ), ))

formMailerAdapterSchema = formMailerAdapterSchema + Schema((
    TALESString(
        'subjectOverride',
        schemata='overrides',
        searchable=0,
        required=0,
        validators=('talesvalidator', ),
        default='',
        write_permission=EDIT_TALES_PERMISSION,
        read_permission=ModifyPortalContent,
        isMetadata=True,  # just to hide from base view
        widget=StringWidget(
            label=_(u'label_subject_override_text',
                    default=u"Subject Expression"),
            description=_(u'help_subject_override_text',
                          default=u"""
                A TALES expression that will be evaluated to override any value
                otherwise entered for the e-mail subject header.
                Leave empty if unneeded. Your expression should evaluate as a string.
                PLEASE NOTE: errors in the evaluation of this expression will cause
                an error on form display.
            """),
            size=70,
        ),
    ),
    TALESString(
        'senderOverride',
        schemata='overrides',
        searchable=0,
コード例 #8
0
from Products.PloneFormGen.interfaces import IPloneFormGenActionAdapter

FormAdapterSchema = ATContentTypeSchema.copy() + Schema((
    TALESString(
        'execCondition',
        schemata='overrides',
        searchable=0,
        required=0,
        validators=('talesvalidator', ),
        default='',
        write_permission=EDIT_TALES_PERMISSION,
        read_permission=ModifyPortalContent,
        isMetadata=True,  # just to hide from base view
        widget=StringWidget(
            label=_('label_execcondition_text', default="Execution Condition"),
            description=_('help_execcondition_text',
                          default="""
                A TALES expression that will be evaluated to determine whether or not
                to execute this action.
                Leave empty if unneeded, and the action will be executed.
                Your expression should evaluate as a boolean; return True if you wish
                the action to execute.
                PLEASE NOTE: errors in the evaluation of this expression will cause
                an error on form display.
            """),
            size=70,
        ),
    ), ))

finalizeATCTSchema(FormAdapterSchema, folderish=True, moveDiscussion=False)
コード例 #9
0
ファイル: test_field.py プロジェクト: Vinsurya/Plone
 def afterSetUp(self):
     PloneTestCase.PloneTestCase.afterSetUp(self)
     self.field = TALESString('tales')
     self.folder.validate_field = lambda *args, **kw: None
コード例 #10
0
ファイル: test_field.py プロジェクト: Vinsurya/Plone
class TALESStringTest(PloneTestCase.PloneTestCase):

    def afterSetUp(self):
        PloneTestCase.PloneTestCase.afterSetUp(self)
        self.field = TALESString('tales')
        self.folder.validate_field = lambda *args, **kw: None

    def validate(self, value):
        errors = {}
        res = self.field.validate(value, self.folder, errors)
        return res, errors

    def test_defaults(self):
        self.assertEquals(self.field.get(self.folder), True)

    def test_getRaw(self):
        self.assertEquals(self.field.getRaw(self.folder), 'python: True')

    def test_set(self):
        self.assertEquals(self.field.get(self.folder), True)
        self.folder.setTitle('bar')
        self.field.set(self.folder, "python: object.Title() == 'foo'")
        self.assertEquals(self.field.get(self.folder), False)
        self.field.set(self.folder, "python: object.Title() == 'bar'")
        self.assertEquals(self.field.get(self.folder), True)

    def test_set_expr(self):
        # Just make sure setting Expression works too.
        default_expr = self.field.getDefault(self.folder)
        self.field.set(self.folder, default_expr)
        self.assertEquals(self.field.getRaw(self.folder), default_expr.text)

    def test_validate(self):
        self.assertEquals(self.validate('python: True'), (None, {}))
        self.assertEquals(
            self.validate('python: 1 + (2 * 3'),
            ('TALES expression "python: 1 + (2 * 3" has errors.', {}))

    def test_valueIsEmptyString(self):
        self.field.set(self.folder, "")
        self.assertEquals(self.field.get(self.folder), None)
        schemata='confirmation',
    ),
    TALESString(
        'confirmationRecipientOverride',
        schemata='overrides',
        searchable=0,
        required=0,
        validators=('talesvalidator', ),
        default='',
        write_permission=EDIT_TALES_PERMISSION,
        read_permission=permissions.ModifyPortalContent,
        isMetadata=True,  # just to hide from base view
        widget=atapi.StringWidget(
            label=_(u'label_recipient_override_text',
                    default=u"Confirmation Recipient Expression"),
            description=_(
                u'help_recipient_override_text',
                default=u"""
                    A TALES expression that will be evaluated to override any value
                    otherwise entered for the confirmation recipient e-mail address. You are strongly
                    cautioned against using unvalidated data from the request for this purpose.
                    Leave empty if unneeded. Your expression should evaluate as a string.
                    PLEASE NOTE: errors in the evaluation of this expression will cause
                    an error on form display.
                """,
            ),
            size=70,
        ),
    ),
))
confirmedFormMailerAdapterSchema = formMailerAdapterSchema.copy(