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


Python config.ConfigurationMachine类代码示例

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


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

示例1: grok

def grok(*module_names):
    config = ConfigurationMachine()
    zcml.do_grok('grokcore.component.compat', config)
    zcml.do_grok('grokcore.component.meta', config)
    for module_name in module_names:
        zcml.do_grok(module_name, config)
    config.execute_actions()
开发者ID:icemac,项目名称:grokcore.component,代码行数:7,代码来源:testing.py

示例2: grok

def grok(module_name):
    config = ConfigurationMachine()
    zcml.do_grok('grokcore.component.meta', config)
    zcml.do_grok('grokcore.security.meta', config)
    zcml.do_grok('grokcore.security.testing', config)
    zcml.do_grok(module_name, config)
    config.execute_actions()
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:7,代码来源:testing.py

示例3: test_after_outside_forms_context

    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,代码行数:25,代码来源:test_zcml.py

示例4: load_zcml

 def load_zcml(self, zcml_asset_specification):
     def _get_site_manager(context=None):
         return self
     if ':' not in zcml_asset_specification:
         import alpaca
         config_package = alpaca
         config_file = zcml_asset_specification
     else:
         package_name, config_file = zcml_asset_specification.split(':')
         __import__(package_name)
         config_package = sys.modules[package_name]
     context = ConfigurationMachine()
     context.package = config_package
     xmlconfig.registerCommonDirectives(context)
     xmlconfig.file(
         config_file,
         package=config_package,
         context=context,
         execute=False
     )
     getSiteManager.sethook(_get_site_manager)
     try:
         context.execute_actions()
     finally:
         getSiteManager.reset()
开发者ID:msiedlarek,项目名称:alpaca,代码行数:25,代码来源:registry.py

示例5: configure

def configure(arguments):
    # Enable venuasianconfiguration
    if HAS_VENUSIANCONFIGURATION:
        import venusianconfiguration
        venusianconfiguration.enable()

    # BBB: Support Zope's global configuration context
    if HAS_ZOPE:
        try:
            import Zope2.App.zcml
            config = Zope2.App.zcml._context or ConfigurationMachine()
        except (ImportError, AttributeError):
            config = ConfigurationMachine()
    else:
        config = ConfigurationMachine()

    # Parse and evaluate configuration and plugins
    registerCommonDirectives(config)

    import transmogrifier
    xmlconfig.include(config, package=transmogrifier, file='meta.zcml')
    xmlconfig.include(config, package=transmogrifier, file='configure.zcml')

    # Resolve includes
    for include in set(arguments.get('--include')):
        package, filename = parse_include(include)
        if package and filename:
            package = importlib.import_module(package)
            xmlconfig.include(config, package=package, file=filename)
        elif package and HAS_VENUSIANCONFIGURATION:
            # Support including single module in the current working directory
            import venusianconfiguration
            venusianconfiguration.venusianscan(package, config)

    config.execute_actions()
开发者ID:collective,项目名称:transmogrifier,代码行数:35,代码来源:main.py

示例6: grok

def grok(module_name=None):
    """Grok a module.

    Test helper to 'grok' a module named by `module_name`, a dotted
    path to a module like ``'mypkg.mymodule'``. 'grokking' hereby
    means to do all the ZCML configurations triggered by directives
    like ``grok.context()`` etc. This is only needed if your module
    was not `grokked` during test setup time as it normally happens
    with functional tests.
    """
    config = ConfigurationMachine()
    zcml.do_grok('grokcore.component.meta', config)
    zcml.do_grok('grokcore.security.meta', config)
    zcml.do_grok('grokcore.view.meta', config)
    zcml.do_grok('grokcore.view.templatereg', config)
    zcml.do_grok('grokcore.viewlet.meta', config)
    zcml.do_grok('grokcore.formlib.meta', config)
    zcml.do_grok('grokcore.annotation.meta', config)
    zcml.do_grok('grokcore.site.meta', config)
    zcml.do_grok('grokcore.catalog.meta', config)
    zcml.do_grok('grokcore.traverser.meta', config)
    zcml.do_grok('grokcore.rest.meta', config)
    zcml.do_grok('grokcore.xmlrpc.meta', config)
    if module_name is not None:
        zcml.do_grok(module_name, config)
    config.execute_actions()
开发者ID:clozinski,项目名称:grok,代码行数:26,代码来源:testing.py

示例7: test_w_file_passed

 def test_w_file_passed(self):
     from zope.configuration import xmlconfig
     from zope.configuration.config import ConfigurationMachine
     from zope.configuration.xmlconfig import registerCommonDirectives
     from zope.configuration import tests
     from zope.configuration.tests import simple
     context = ConfigurationMachine()
     registerCommonDirectives(context)
     before_stack = context.stack[:]
     context.package = tests
     fqn = _packageFile(tests, 'simple.zcml')
     logger = LoggerStub()
     with _Monkey(xmlconfig, logger=logger):
         self._callFUT(context, 'simple.zcml')
     self.assertEqual(len(logger.debugs), 1)
     self.assertEqual(logger.debugs[0], ('include %s', (fqn,), {}))
     self.assertEqual(len(context.actions), 3)
     action = context.actions[0]
     self.assertEqual(action['callable'], simple.file_registry.append)
     self.assertEqual(action['includepath'], (fqn,))
     self.assertEqual(action['args'][0].path,
                      _packageFile(tests, 'simple.py'))
     action = context.actions[1]
     self.assertEqual(action['callable'], simple.file_registry.append)
     self.assertEqual(action['includepath'], (fqn,))
     self.assertEqual(action['args'][0].path,
                      _packageFile(tests, 'simple.zcml'))
     action = context.actions[2]
     self.assertEqual(action['callable'], simple.file_registry.append)
     self.assertEqual(action['includepath'], (fqn,))
     self.assertEqual(action['args'][0].path,
                      _packageFile(tests, '__init__.py'))
     self.assertEqual(context.stack, before_stack)
     self.assertEqual(len(context._seen_files), 1)
     self.assertIn(fqn, context._seen_files)
开发者ID:zopefoundation,项目名称:zope.configuration,代码行数:35,代码来源:test_xmlconfig.py

示例8: __main__

def __main__():
    # Enable logging
    logging.basicConfig(level=logging.INFO)

    # Parse cli arguments
    arguments = docopt(__doc__)

    # Parse and evaluate configuration and plugins
    config = ConfigurationMachine()
    registerCommonDirectives(config)
    xmlconfig.include(config, package=collective.transmogrifier,
                      file='meta.zcml')
    xmlconfig.include(config, package=collective.transmogrifier,
                      file='configure.zcml')
    config.execute_actions()

    if arguments.get('--list'):
        blueprints = dict(getUtilitiesFor(ISectionBlueprint))
        pipelines = map(configuration_registry.getConfiguration,
                        configuration_registry.listConfigurationIds())
        print """
Available blueprints
--------------------
{0:s}

Available pipelines
-------------------
{1:s}
""".format('\n'.join(sorted(blueprints.keys())),
           '\n'.join(['{0:s}\n    {1:s}: {2:s}'.format(
                      p['id'], p['title'], p['description'])
                      for p in pipelines]))
        return

    # Load optional overrides
    overrides = {}
    overrides_path = arguments.get('--overrides')
    if overrides_path and not os.path.isabs(overrides_path):
        overrides_path = os.path.join(os.getcwd(), overrides_path)
    if overrides_path:
        parser = ConfigParser.RawConfigParser()
        parser.optionxform = str  # case sensitive
        with open(overrides_path) as fp:
            parser.readfp(fp)
        overrides.update(dict(((section, dict(parser.items(section)))
                               for section in parser.sections())))

    # Initialize optional context
    context_path = arguments.get('--context')
    if context_path is None:
        context = dict()
    else:
        context_module_path, context_class_name = context_path.rsplit('.', 1)
        context_module = importlib.import_module(context_module_path)
        context = getattr(context_module, context_class_name)()

    # Transmogrify
    for pipeline in arguments.get('<pipeline>'):
        ITransmogrifier(context)(pipeline, **overrides)
开发者ID:datakurre,项目名称:collective.transmogrifier,代码行数:59,代码来源:runner.py

示例9: grok

def grok(module_name):
    config = ConfigurationMachine()
    zcml.do_grok('grokcore.component.meta', config)
    zcml.do_grok('grokcore.security.meta', config)
    zcml.do_grok('grokcore.view.meta', config)
    zcml.do_grok('grokcore.view.templatereg', config)
    zcml.do_grok('grokcore.permission', config)
    zcml.do_grok(module_name, config)
    config.execute_actions()
开发者ID:jean,项目名称:grokcore.permission,代码行数:9,代码来源:testing.py

示例10: test_neither_file_nor_files_passed

 def test_neither_file_nor_files_passed(self):
     from zope.configuration.config import ConfigurationMachine
     from zope.configuration.tests import samplepackage
     context = ConfigurationMachine()
     context.package = samplepackage
     fqn = _packageFile(samplepackage, 'configure.zcml')
     self._callFUT(context)
     self.assertEqual(len(context.actions), 0)
     self.assertEqual(len(context._seen_files), 1)
     self.assertIn(fqn, context._seen_files)
开发者ID:zopefoundation,项目名称:zope.configuration,代码行数:10,代码来源:test_xmlconfig.py

示例11: zcml_configure

def zcml_configure(name, package):
    """ Given a ZCML filename as ``name`` and a Python package as
    ``package`` which the filename should be relative to, load the
    ZCML into the current ZCML registry.

    """
    context = ConfigurationMachine()
    xmlconfig.registerCommonDirectives(context)
    context.package = package
    xmlconfig.include(context, name, package)
    context.execute_actions(clear=False) # the raison d'etre
    return context.actions
开发者ID:markramm,项目名称:pyramid,代码行数:12,代码来源:zcml.py

示例12: configure

 def configure(self):
     gsm = component.getGlobalSiteManager
     component.getGlobalSiteManager = get_current_registry
     manager.push({'registry': self.registry})
     try:
         context = ConfigurationMachine()
         for action in self():
             context.action(*action)
         context.execute_actions()
     finally:
         component.getGlobalSiteManager = gsm
         manager.pop()
开发者ID:malthe,项目名称:repoze.bfg.skins,代码行数:12,代码来源:zcml.py

示例13: grok

def grok(module_name):
    config = ConfigurationMachine()
    zcml.do_grok('grokcore.component.meta', config)
    zcml.do_grok('grokcore.view.meta.views', config)
    zcml.do_grok('grokcore.view.meta.templates', config)
    zcml.do_grok('grokcore.view.meta.skin', config)
    # Use the Five override for the page template factory
    # zcml.do_grok('grokcore.view.templatereg', config)
    zcml.do_grok('five.grok.templatereg', config)
    zcml.do_grok('five.grok.meta', config)
    zcml.do_grok(module_name, config)
    config.execute_actions()
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:12,代码来源:testing.py

示例14: grok

def grok(module_name):
    config = ConfigurationMachine()
    zcml.do_grok('grokcore.component.meta', config)
    zcml.do_grok('grokcore.security.meta', config)
    zcml.do_grok('grokcore.view.meta', config)
    zcml.do_grok('grokcore.view.templatereg', config)
    zcml.do_grok('grokcore.viewlet.meta', config)
    zcml.do_grok('grokcore.formlib.meta', config)
    zcml.do_grok('grokcore.annotation.meta', config)
    zcml.do_grok('grokcore.site.meta', config)
    zcml.do_grok('grok.meta', config)
    zcml.do_grok(module_name, config)
    config.execute_actions()
开发者ID:grodniewicz,项目名称:oship,代码行数:13,代码来源:testing.py

示例15: load_zcml

def load_zcml(*args):
    """We rely on grok to load the configuration for our modules, but we depend on some libraries which
    have only zcml based configuration, thus we need to load only those we need."""

    from zope.configuration.config import ConfigurationMachine
    from zope.configuration import xmlconfig

    context = ConfigurationMachine()
    xmlconfig.registerCommonDirectives(context)

    for i in args:
        xmlconfig.include(context, "configure.zcml", context.resolve(i))

    context.execute_actions()
开发者ID:carriercomm,项目名称:opennode-management,代码行数:14,代码来源:core.py


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