Example #1
0
class IRendererDirective(Interface):
    factory = GlobalObject(title=u('IRendererFactory implementation'),
                           required=True)

    name = TextLine(
        title=u('Token (e.g. ``json``) or filename extension (e.g. ".pt")'),
        required=False)
Example #2
0
class IAssetDirective(Interface):
    """
    Directive for specifying that one package may override assets from
    another package.
    """
    to_override = TextLine(title=u('Override spec'),
                           description=u('The spec of the asset to override.'),
                           required=True)
    override_with = TextLine(
        title=u('With spec'),
        description=u('The spec of the asset providing the override.'),
        required=True)
Example #3
0
class IUtilityDirective(Interface):
    """Register a utility."""

    component = GlobalObject(
        title=u('Component to use'),
        description=(u('Python name of the implementation object.  This '
                       'must identify an object in a module using the '
                       'full dotted name.  If specified, the '
                       '``factory`` field must be left blank.')),
        required=False,
    )

    factory = GlobalObject(
        title=u('Factory'),
        description=(u('Python name of a factory which can create the '
                       'implementation object.  This must identify an '
                       'object in a module using the full dotted name. '
                       'If specified, the ``component`` field must '
                       'be left blank.')),
        required=False,
    )

    provides = GlobalInterface(
        title=u('Provided interface'),
        description=u('Interface provided by the utility.'),
        required=False,
    )

    name = TextLine(
        title=u('Name'),
        description=(u('Name of the registration.  This is used by '
                       'application code when locating a utility.')),
        required=False,
    )
Example #4
0
class IAdapterDirective(Interface):
    """
    Register an adapter
    """

    factory = Tokens(title=u('Adapter factory/factories'),
                     description=(u(
                         'A list of factories (usually just one) that create '
                         'the adapter instance.')),
                     required=True,
                     value_type=GlobalObject())

    provides = GlobalInterface(
        title=u('Interface the component provides'),
        description=(u('This attribute specifies the interface the adapter '
                       'instance must provide.')),
        required=False,
    )

    for_ = Tokens(
        title=u('Specifications to be adapted'),
        description=u('This should be a list of interfaces or classes'),
        required=False,
        value_type=GlobalObject(missing_value=object(), ),
    )

    name = TextLine(
        title=u('Name'),
        description=(u('Adapters can have names.\n\n'
                       'This attribute allows you to specify the name for '
                       'this adapter.')),
        required=False,
    )
Example #5
0
class ISubscriberDirective(Interface):
    """
    Register a subscriber
    """

    factory = GlobalObject(
        title=u('Subscriber factory'),
        description=u('A factory used to create the subscriber instance.'),
        required=False,
    )

    handler = GlobalObject(
        title=u('Handler'),
        description=u('A callable object that handles events.'),
        required=False,
    )

    provides = GlobalInterface(
        title=u('Interface the component provides'),
        description=u('This attribute specifies the interface the adapter '
                      'instance must provide.'),
        required=False,
    )

    for_ = Tokens(
        title=u('Interfaces or classes that this subscriber depends on'),
        description=u('This should be a list of interfaces or classes'),
        required=False,
        value_type=GlobalObject(missing_value=object(), ),
    )
Example #6
0
class ISystemViewDirective(Interface):
    view = GlobalObject(
        title=_BLANK,
        description=u('The view function'),
        required=False,
    )

    attr = TextLine(title=u(
        'The callable attribute of the view object(default is __call__)'),
                    description=_BLANK,
                    required=False)

    renderer = TextLine(title=u('The renderer asssociated with the view'),
                        description=_BLANK,
                        required=False)

    wrapper = TextLine(title=u(
        'The *name* of the view that acts as a wrapper for this view.'),
                       description=_BLANK,
                       required=False)
Example #7
0
class IStaticDirective(Interface):
    name = TextLine(
        title=u('The URL prefix of the static view'),
        description=u(
            'The directory will be served up for the route that starts with '
            'this prefix.'),
        required=True)

    path = TextLine(
        title=u('Path to the directory which contains assets'),
        description=u(
            'May be package-relative by using a colon to separate package '
            'name and path relative to the package directory.'),
        required=True)

    cache_max_age = Int(title=u('Cache maximum age in seconds'),
                        required=False,
                        default=None)

    permission = TextLine(title=u('Permission string'),
                          description=u('The permission string'),
                          required=False)
Example #8
0
class ILocaleNegotiatorDirective(Interface):
    negotiator = GlobalObject(
        title=u('Configure a locale negotiator'),
        required=True,
    )
Example #9
0
class ITranslationDirDirective(Interface):
    dir = TextLine(
        title=u('Add a translation directory'),
        required=True,
    )
Example #10
0
class IScanDirective(Interface):
    package = GlobalObject(
        title=u('The package we would like to scan.'),
        required=True,
    )
Example #11
0
from zope.schema import TextLine

from pyramid.authentication import AuthTktAuthenticationPolicy
from pyramid.authentication import RemoteUserAuthenticationPolicy
from pyramid.authentication import RepozeWho1AuthenticationPolicy
from pyramid.authorization import ACLAuthorizationPolicy
from pyramid.config import Configurator
from pyramid.exceptions import ConfigurationError
from pyramid.asset import asset_spec_from_abspath
from pyramid.threadlocal import get_current_registry

from zope.configuration import xmlconfig

from pyramid_zcml._compat import u

_BLANK = u('')

###################### directives ##########################


class IViewDirective(Interface):
    context = GlobalObject(title=u('The interface or class this view is for.'),
                           required=False)

    for_ = GlobalObject(title=u(
        'The interface or class this view is for (alternate spelling '
        'of ``context``).'),
                        required=False)

    permission = TextLine(
        title=u('Permission'),
Example #12
0
class IRepozeWho1AuthenticationPolicyDirective(Interface):
    identifier_name = TextLine(title=u('identitfier_name'),
                               required=False,
                               default=u('auth_tkt'))
    callback = GlobalObject(title=u('callback'), required=False)
Example #13
0
class IViewDirective(Interface):
    context = GlobalObject(title=u('The interface or class this view is for.'),
                           required=False)

    for_ = GlobalObject(title=u(
        'The interface or class this view is for (alternate spelling '
        'of ``context``).'),
                        required=False)

    permission = TextLine(
        title=u('Permission'),
        description=u('The permission needed to use the view.'),
        required=False)

    view = GlobalObject(
        title=_BLANK,
        description=u('The view function'),
        required=False,
    )

    name = TextLine(
        title=u('The name of the view'),
        description=u(
            'Shows up in URLs/paths. For example "foo" or "foo.html".'),
        required=False,
    )

    attr = TextLine(title=u(
        'The callable attribute of the view object(default is __call__)'),
                    description=_BLANK,
                    required=False)

    renderer = TextLine(title=u('The renderer asssociated with the view'),
                        description=_BLANK,
                        required=False)

    wrapper = TextLine(title=u(
        'The *name* of the view that acts as a wrapper for this view.'),
                       description=_BLANK,
                       required=False)

    request_type = GlobalObject(
        title=u('The dotted name interface for the request type'),
        description=u(
            'The view will be called if the interface represented by '
            '"request_type" is implemented by the request.  The '
            'default request type is pyramid.interfaces.IRequest'),
        required=False)

    route_name = TextLine(
        title=u('The route that must match for this view to be used'),
        required=False)

    containment = GlobalObject(
        title=u('Dotted name of a containment class or interface'),
        required=False)

    request_method = TextLine(
        title=u('Request method name that must be matched (e.g. GET/POST)'),
        description=u('The view will be called if and only if the request '
                      'method (``request.method``) matches this string.'),
        required=False)

    request_param = TextLine(
        title=u('Request parameter name that must exist in '
                '``request.params`` for this view to match'),
        description=u('The view will be called if and only if the request '
                      'parameter exists which matches this string.'),
        required=False)

    xhr = Bool(
        title=u('True if request has an X-Requested-With header with the '
                'value "XMLHttpRequest"'),
        description=u('Useful for detecting AJAX requests issued from '
                      'jQuery, Protoype and other JavaScript libraries'),
        required=False)

    accept = TextLine(
        title=u('Mimetype(s) that must be present in "Accept" HTTP header '
                'for the view to match a request'),
        description=u('Accepts a mimetype match token in the form '
                      '"text/plain", a wildcard mimetype match token in the '
                      'form "text/*" or a match-all wildcard mimetype match '
                      'token in the form "*/*".'),
        required=False)

    header = TextLine(
        title=u('Header name/value pair in the form "name=<regex>"'),
        description=u('Regular expression matching for header values'),
        required=False)

    path_info = TextLine(title=u(
        'Regular expression which must match the ``PATH_INFO`` '
        'header for the view to match a request'),
                         description=u('Accepts a regular expression.'),
                         required=False)

    decorator = GlobalObject(title=u('View decorator'), required=False)

    mapper = GlobalObject(title=u('View mapper'), required=False)

    custom_predicates = Tokens(
        title=u(
            "One or more custom dotted names to custom predicate callables"),
        description=u(
            'A list of dotted name references to callables that '
            'will be used as predicates for this view configuration'),
        required=False,
        value_type=GlobalObject())
Example #14
0
class IRouteDirective(IRouteLikeDirective):
    name = TextLine(title=u('name'), required=True)
    # alias for pattern
    path = TextLine(title=u('path'), required=False)
Example #15
0
class IRouteLikeDirective(Interface):
    """ The interface for the ``route`` ZCML directive
    """
    pattern = TextLine(title=u('pattern'), required=False)
    factory = GlobalObject(title=u('context factory'), required=False)
    view = GlobalObject(title=u('view'), required=False)

    view_context = GlobalObject(title=u('view_context'), required=False)
    # aliases for view_context
    for_ = GlobalObject(title=u('for'), required=False)
    view_for = GlobalObject(title=u('view_for'), required=False)

    view_permission = TextLine(title=u('view_permission'), required=False)
    # alias for view_permission
    permission = TextLine(title=u('permission'), required=False)

    view_renderer = TextLine(title=u('view_renderer'), required=False)
    # alias for view_renderer
    renderer = TextLine(title=u('renderer'), required=False)

    view_attr = TextLine(title=u('view_attr'), required=False)

    request_method = TextLine(title=u('request_method'), required=False)
    request_param = TextLine(title=u('request_param'), required=False)
    header = TextLine(title=u('header'), required=False)
    accept = TextLine(title=u('accept'), required=False)
    xhr = Bool(title=u('xhr'), required=False)
    path_info = TextLine(title=u('path_info'), required=False)

    traverse = TextLine(
        title=u('Traverse pattern'),
        description=u('A pattern which will compose a traversal path'),
        required=False)

    custom_predicates = Tokens(
        title=u(
            "One or more custom dotted names to custom predicate callables"),
        description=u(
            'A list of dotted name references to callables that '
            'will be used as predicates for this view configuration'),
        required=False,
        value_type=GlobalObject())
    use_global_views = Bool(title=u('use_global_views'), required=False)
Example #16
0
class IRemoteUserAuthenticationPolicyDirective(Interface):
    environ_key = TextLine(title=u('environ_key'),
                           required=False,
                           default=u('REMOTE_USER'))
    callback = GlobalObject(title=u('callback'), required=False)
Example #17
0
class IAuthTktAuthenticationPolicyDirective(Interface):
    secret = TextLine(title=u('secret'), required=True)
    callback = GlobalObject(title=u('callback'), required=False)
    cookie_name = ASCIILine(title=u('cookie_name'),
                            required=False,
                            default='auth_tkt')
    secure = Bool(title=u('secure'), required=False, default=False)
    include_ip = Bool(title=u('include_ip'), required=False, default=False)
    timeout = Int(title=u('timeout'), required=False, default=None)
    reissue_time = Int(title=u('reissue_time'), required=False, default=None)
    max_age = Int(title=u('max_age'), required=False, default=None)
    path = ASCIILine(title=u('path'), required=False, default='/')
    http_only = Bool(title=u('http_only'), required=False, default=False)
    wild_domain = Bool(title=u('wild_domain'), required=False, default=True)
Example #18
0
class IDefaultPermissionDirective(Interface):
    name = TextLine(title=u('name'), required=True)
Example #19
0
from zope.schema import TextLine

from pyramid.authentication import AuthTktAuthenticationPolicy
from pyramid.authentication import RemoteUserAuthenticationPolicy
from pyramid.authentication import RepozeWho1AuthenticationPolicy
from pyramid.authorization import ACLAuthorizationPolicy
from pyramid.config import Configurator
from pyramid.exceptions import ConfigurationError
from pyramid.asset import asset_spec_from_abspath, resolve_asset_spec
from pyramid.threadlocal import get_current_registry

from zope.configuration import xmlconfig

from pyramid_zcml._compat import u

_BLANK = u('')

###################### directives ##########################

class IViewDirective(Interface):
    context = GlobalObject(
        title=u('The interface or class this view is for.'),
        required=False
        )

    for_ = GlobalObject(
        title=u('The interface or class this view is for (alternate spelling '
                'of ``context``).'),
        required=False
        )