Exemple #1
0
import zope.interface
import zope.component
import zope.location
import zope.schema.interfaces
from zope.browserpage.viewpagetemplatefile import ViewPageTemplateFile
from zope.i18n import translate
from zope.pagetemplate.interfaces import IPageTemplate
from zope.schema.fieldproperty import FieldProperty

from z3c.form import interfaces, util, value

PLACEHOLDER = object()

StaticWidgetAttribute = value.StaticValueCreator(
    discriminators=('context', 'request', 'view', 'field', 'widget')
    )
ComputedWidgetAttribute = value.ComputedValueCreator(
    discriminators=('context', 'request', 'view', 'field', 'widget')
    )


@zope.interface.implementer(interfaces.IWidget)
class Widget(zope.location.Location):
    """Widget base class."""

    # widget specific attributes
    name = FieldProperty(interfaces.IWidget['name'])
    label = FieldProperty(interfaces.IWidget['label'])
    mode = FieldProperty(interfaces.IWidget['mode'])
    required = FieldProperty(interfaces.IWidget['required'])
Exemple #2
0
__docformat__ = "reStructuredText"
import sys
import zope.event
import zope.interface
import zope.location
import zope.schema
import zope.traversing.api

from zope.app.component import hooks
from zope.interface import adapter
from zope.schema.fieldproperty import FieldProperty
from z3c.form import action, interfaces, util, value
from z3c.form.browser import image, submit
from z3c.form.widget import AfterWidgetUpdateEvent

StaticButtonActionAttribute = value.StaticValueCreator(
    discriminators=('form', 'request', 'content', 'button', 'manager'))
ComputedButtonActionAttribute = value.ComputedValueCreator(
    discriminators=('form', 'request', 'content', 'button', 'manager'))


class Button(zope.schema.Field):
    """A simple button in a form."""
    zope.interface.implements(interfaces.IButton)

    accessKey = FieldProperty(interfaces.IButton['accessKey'])
    actionFactory = FieldProperty(interfaces.IButton['actionFactory'])

    def __init__(self, *args, **kwargs):
        # Provide some shortcut ways to specify the name
        if args:
            kwargs['__name__'] = args[0]
Exemple #3
0
$Id$
"""
__docformat__ = "reStructuredText"
import os
import zope.component
import zope.interface
import zope.schema
from zope.browserpage.viewpagetemplatefile import ViewPageTemplateFile
from zope.pagetemplate.interfaces import IPageTemplate

import z3c.form
from z3c.form import interfaces, util, value
from z3c.form.i18n import MessageFactory as _

ErrorViewMessage = value.StaticValueCreator(discriminators=('error', 'request',
                                                            'widget', 'field',
                                                            'form', 'content'))

ComputedErrorViewMessage = value.ComputedValueCreator(
    discriminators=('error', 'request', 'widget', 'field', 'form', 'content'))


def ErrorViewDiscriminators(errorView,
                            error=None,
                            request=None,
                            widget=None,
                            field=None,
                            form=None,
                            content=None):
    zope.component.adapter(util.getSpecification(error),
                           util.getSpecification(request),