当前位置: 首页>>代码示例>>Python>>正文


Python ConfigurationMachine.route_prefix方法代码示例

本文整理汇总了Python中zope.configuration.config.ConfigurationMachine.route_prefix方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigurationMachine.route_prefix方法的具体用法?Python ConfigurationMachine.route_prefix怎么用?Python ConfigurationMachine.route_prefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在zope.configuration.config.ConfigurationMachine的用法示例。


在下文中一共展示了ConfigurationMachine.route_prefix方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_after_outside_forms_context

# 需要导入模块: from zope.configuration.config import ConfigurationMachine [as 别名]
# 或者: from zope.configuration.config.ConfigurationMachine import route_prefix [as 别名]
    def test_after_outside_forms_context(self):
        import webob.multidict
        import schemaish
        from pyramid.view import render_view_to_response
        from pyramid_formish.zcml import FormAction
        from zope.configuration.config import ConfigurationMachine
        context = ConfigurationMachine()
        context.route_prefix = ''
        context.autocommit = True
        context.registry = self.config.registry
        request = testing.DummyRequest()
        request.registry = self.config.registry
        title = schemaish.String()
        factory = make_controller_factory(fields=[('title', title)])
        directive = self._makeOne(context, factory)
        directive._actions = [FormAction('submit','title',True)]
        directive.after()
        display = render_view_to_response(None, request, '')
        self.assertEqual(display.body, '123')

        request = testing.DummyRequest()
        request.params = webob.multidict.MultiDict()
        request.params['submit'] = True
        display = render_view_to_response(None, request, '')
        self.assertEqual(display.body, 'submitted')
开发者ID:Pylons,项目名称:pyramid_formish,代码行数:27,代码来源:test_zcml.py

示例2: xmlconfig

# 需要导入模块: from zope.configuration.config import ConfigurationMachine [as 别名]
# 或者: from zope.configuration.config.ConfigurationMachine import route_prefix [as 别名]
        def xmlconfig(s, config=config):
            from zope.configuration.config import ConfigurationMachine
            from zope.configuration.xmlconfig import registerCommonDirectives
            from zope.configuration.xmlconfig import string

            context = ConfigurationMachine()
            context.autocommit = True
            context.registry = config.registry
            context.route_prefix = None
            context.actions = config.action_state.actions

            registerCommonDirectives(context)

            string(s, context=context, execute=False)
            config.commit()
开发者ID:mmariani,项目名称:pyramid_skins,代码行数:17,代码来源:test_doctests.py

示例3: test_after_render_controller_submission

# 需要导入模块: from zope.configuration.config import ConfigurationMachine [as 别名]
# 或者: from zope.configuration.config.ConfigurationMachine import route_prefix [as 别名]
 def test_after_render_controller_submission(self):
     from pyramid.view import render_view_to_response
     from zope.configuration.config import ConfigurationMachine
     
     context = ConfigurationMachine()
     context.route_prefix = ''
     context.registry = self.config.registry
     context.autocommit = True
     directive = self._makeOne(context, view=None)
     directive.forms = [DummyFormDirective()]
     directive.actions = []
     directive.after()
     request = testing.DummyRequest()
     request.params = {'__formish_form__':'form_id', 'submit':True}
     display = render_view_to_response(None, request, '')
     self.assertEqual(display.body, 'submitted')
     self.assertEqual(len(request.forms), 1)
开发者ID:Pylons,项目名称:pyramid_formish,代码行数:19,代码来源:test_zcml.py

示例4: test_after_render_view

# 需要导入模块: from zope.configuration.config import ConfigurationMachine [as 别名]
# 或者: from zope.configuration.config.ConfigurationMachine import route_prefix [as 别名]
 def test_after_render_view(self):
     from pyramid.view import render_view_to_response
     from zope.configuration.config import ConfigurationMachine
     from pyramid.response import Response
     def view(context, request):
         return Response('response')
     context = ConfigurationMachine()
     context.route_prefix = ''
     context.registry = self.config.registry
     context.autocommit = True
     directive = self._makeOne(context, view=view)
     directive.forms = [DummyFormDirective()]
     directive.actions = []
     directive.after()
     request = testing.DummyRequest()
     display = render_view_to_response(None, request, '')
     self.assertEqual(display.body, 'response')
     self.assertEqual(len(request.forms), 1)
开发者ID:Pylons,项目名称:pyramid_formish,代码行数:20,代码来源:test_zcml.py

示例5: test_after_render_controller_curriedview

# 需要导入模块: from zope.configuration.config import ConfigurationMachine [as 别名]
# 或者: from zope.configuration.config.ConfigurationMachine import route_prefix [as 别名]
 def test_after_render_controller_curriedview(self):
     from pyramid.view import render_view_to_response
     from zope.configuration.config import ConfigurationMachine
     from pyramid_formish import ValidationError
     from pyramid.response import Response
     def view(context, request):
         return Response('response')
     context = ConfigurationMachine()
     context.route_prefix = ''
     context.autocommit = True
     context.registry = self.config.registry
     directive = self._makeOne(context, view=view)
     formdirective = DummyFormDirective()
     formdirective.controller = make_controller_factory(
         exception=ValidationError)
     directive.forms = [formdirective]
     directive.actions = []
     directive.after()
     request = testing.DummyRequest()
     request.params = {'__formish_form__':'form_id', 'submit':True}
     display = render_view_to_response(None, request, '')
     self.assertEqual(display.body, 'response')
     self.assertEqual(len(request.forms), 1)
开发者ID:Pylons,项目名称:pyramid_formish,代码行数:25,代码来源:test_zcml.py

示例6: register_path

# 需要导入模块: from zope.configuration.config import ConfigurationMachine [as 别名]
# 或者: from zope.configuration.config.ConfigurationMachine import route_prefix [as 别名]
def register_path(config, spec, discovery=False, indexes=[], request_type=None):
    """ Add a skin path to the current configuration state.

    If ``discovery`` is enabled, the path will automatically be
    monitored for changes.

    The ``indexes`` argument is an optional list of view registrations
    with the provided names.

    The ``request_type`` option decides the request type for which to
    make the registration.
    """

    package_name, path = resolve_asset_spec(spec)
    if package_name is not None:
        path = pkg_resources.resource_filename(package_name, path)
    else:
        path = caller_path(path)

    if package_name is None: # absolute filename
        package = config.package
    else:
        __import__(package_name)
        package = sys.modules[package_name]
    context = ConfigurationMachine()
    context.registry = config.registry
    context.autocommit = False
    context.package = package
    context.route_prefix = getattr(config, 'route_prefix', None)

    directive = skins(context, path, discovery, request_type)
    for index in indexes:
        directive.view(config, index)

    for action in directive():
        config.action(*action)
开发者ID:mmariani,项目名称:pyramid_skins,代码行数:38,代码来源:configuration.py

示例7: load_zcml

# 需要导入模块: from zope.configuration.config import ConfigurationMachine [as 别名]
# 或者: from zope.configuration.config.ConfigurationMachine import route_prefix [as 别名]
def load_zcml(self, spec='configure.zcml', lock=threading.Lock(), features=()):
    """ Load configuration from a :term:`ZCML` file into the
    current configuration state.  The ``spec`` argument is an
    absolute filename, a relative filename, or a :term:`asset
    specification`, defaulting to ``configure.zcml`` (relative to
    the package of the method's caller).
    
    The ``features`` argument can be any iterable of strings. These are useful
    for conditionally including or excluding parts of a :term:`ZCML` file.
    """
    package_name, filename = self._split_spec(spec)
    if package_name is None: # absolute filename
        package = self.package
    else:
        __import__(package_name)
        package = sys.modules[package_name]

    # To avoid breaking people's expectations of how ZCML works, we
    # cannot autocommit ZCML actions incrementally.  If we commit actions
    # incrementally, configuration outcome will be controlled purely by
    # ZCML directive execution order, which isn't what anyone who uses
    # ZCML expects.  So we don't autocommit each ZCML directive action
    # while parsing is happening, but we do make sure to commit right
    # after parsing if autocommit it True.
    context = ConfigurationMachine()
    for feature in features:
        context.provideFeature(feature)
    context.registry = self.registry
    context.autocommit = False
    context.route_prefix = getattr(self, 'route_prefix', None)
    context.package = package
    registerCommonDirectives(context)

    self.manager.push({'registry':self.registry, 'request':None})
    lock.acquire()

    try:
        # old_action_state will be None for Pyramid 1.0 and 1.1, but
        # not for 1.2
        old_action_state = getattr(self.registry, 'action_state', None)
        if old_action_state is not None:
            # For Pyramid 1.2+, we need to assign a temporary action state to
            # the registry, because the configurator actions must populate
            # the context's action list (instead of the registry action
            # state's action list) in order for includeOverrides to work
            # properly.
            from pyramid.config import ActionState 
            self.registry.action_state = ActionState()
            self.registry.action_state.actions = context.actions
        xmlconfig.file(filename, package, context=context,
                       execute=False)
    finally:
        if old_action_state is not None:
            # if we reassigned the action state, restore the old one (1.2 only)
            self.registry.action_state = old_action_state
        lock.release()
        self.manager.pop()

    _ctx = self._ctx
    if _ctx is None: # pragma: no cover ; will never be true under 1.2a5+
        _ctx = self._ctx = self._make_context(self.autocommit)
    _ctx.actions.extend(context.actions)
    if self.autocommit:
        self.commit()

    return self.registry
开发者ID:jinty,项目名称:pyramid_zcml,代码行数:68,代码来源:__init__.py


注:本文中的zope.configuration.config.ConfigurationMachine.route_prefix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。