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


Python DottedNameResolver.maybe_resolve方法代码示例

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


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

示例1: __init__

# 需要导入模块: from pyramid.path import DottedNameResolver [as 别名]
# 或者: from pyramid.path.DottedNameResolver import maybe_resolve [as 别名]
 def __init__(self, ipaddrs, userid=None, principals=None, proxies=None, get_userid=None, get_principals=None):
     r = DottedNameResolver()
     self.get_userid = r.maybe_resolve(get_userid)
     self.get_principals = r.maybe_resolve(get_principals)
     self.ipaddrs = make_ip_set(ipaddrs)
     self.userid = userid
     if isinstance(principals, basestring):
         self.principals = aslist(principals)
     else:
         self.principals = principals
     self.proxies = make_ip_set(proxies)
开发者ID:SambaDemon,项目名称:pyramid_ipauth,代码行数:13,代码来源:__init__.py

示例2: start_scheduler

# 需要导入模块: from pyramid.path import DottedNameResolver [as 别名]
# 或者: from pyramid.path.DottedNameResolver import maybe_resolve [as 别名]
def start_scheduler(config):
    reader = config.settings_reader()
    settings = reader.settings
    scheduler = reader.read_str('papaye.scheduler')
    scheduler_keys = (key[17:] for key in settings.keys()
                      if key.startswith('papaye.scheduler.'))
    if not reader.read_bool('papaye.cache') or scheduler is None:
        scheduler = DummyScheduler()
    else:
        resolver = DottedNameResolver()
        scheduler_kwargs = {key[17:]: val for key, val in settings.items()
                            if key in scheduler_keys}
        scheduler = resolver.maybe_resolve(scheduler)(**scheduler_kwargs)
    scheduler.start()
    TaskRegistry().register_scheduler(scheduler)

    def get_scheduler(request):

        return scheduler

    config.add_request_method(
        get_scheduler,
        'scheduler',
        property=True,
        reify=True
    )
开发者ID:rcommande,项目名称:papaye,代码行数:28,代码来源:startup.py

示例3: get_db_session

# 需要导入模块: from pyramid.path import DottedNameResolver [as 别名]
# 或者: from pyramid.path.DottedNameResolver import maybe_resolve [as 别名]
def get_db_session(request, settings=None):
    if settings is None:
        settings = request.registry.settings
    session_path = settings.get('bowab.db_session', DBSession)
    resolver = DottedNameResolver()
    db_session = resolver.maybe_resolve(session_path)
    return db_session
开发者ID:davidblewett,项目名称:sixfeetup.bowab,代码行数:9,代码来源:base.py

示例4: main

# 需要导入模块: from pyramid.path import DottedNameResolver [as 别名]
# 或者: from pyramid.path.DottedNameResolver import maybe_resolve [as 别名]
def main(argv=sys.argv, processor=None):
    logger = logging.getLogger(__name__)

    if len(argv) != 2:
        usage(argv)
    config_uri = argv[1]
    setup_logging(config_uri)
    settings = get_appsettings(config_uri)
    settings = setup_database({}, **settings)

    session = settings['session']
    subscription_model = SubscriptionModel(session)
    tx_model = TransactionModel(session)

    maximum_retry = int(settings.get(
        'billy.transaction.maximum_retry', 
        TransactionModel.DEFAULT_MAXIMUM_RETRY,
    ))

    resolver = DottedNameResolver()
    if processor is None:
        processor_factory = settings['billy.processor_factory']
        processor_factory = resolver.maybe_resolve(processor_factory)
        processor = processor_factory()

    # yield all transactions and commit before we process them, so that
    # we won't double process them. 
    with db_transaction.manager:
        logger.info('Yielding transaction ...')
        subscription_model.yield_transactions()

    with db_transaction.manager:
        logger.info('Processing transaction ...')
        tx_model.process_transactions(processor, maximum_retry=maximum_retry)
    logger.info('Done')
开发者ID:JeffersonK,项目名称:billy,代码行数:37,代码来源:process_transactions.py

示例5: __new__

# 需要导入模块: from pyramid.path import DottedNameResolver [as 别名]
# 或者: from pyramid.path.DottedNameResolver import maybe_resolve [as 别名]
 def __new__(cls, namespace, base, *args, **kw):
     # Dotted name support makes it easy to configure with pyramid_multiauth
     name_resolver = DottedNameResolver(caller_package())
     base = name_resolver.maybe_resolve(base)
     # Dynamically create a subclass
     name = 'Namespaced_%s_%s' % (namespace, base.__name__)
     klass = type(name, (cls, base), {'_namespace_prefix': namespace + '.'})
     return super(NamespacedAuthenticationPolicy, klass).__new__(klass)
开发者ID:ClinGen,项目名称:clincoded,代码行数:10,代码来源:authentication.py

示例6: add_logging

# 需要导入模块: from pyramid.path import DottedNameResolver [as 别名]
# 或者: from pyramid.path.DottedNameResolver import maybe_resolve [as 别名]
def add_logging(config, log_key, log_func=None):
    resolver = DottedNameResolver()
    if log_func is None:
        log_func = operator.attrgetter(log_key)
    log_func = resolver.maybe_resolve(log_func)

    config.registry[get_key("registered_loggers")][log_key] = log_func
    config.registry[get_key("order")].append(log_key)
开发者ID:dobrite,项目名称:notaliens.com,代码行数:10,代码来源:log.py

示例7: get_processor_factory

# 需要导入模块: from pyramid.path import DottedNameResolver [as 别名]
# 或者: from pyramid.path.DottedNameResolver import maybe_resolve [as 别名]
def get_processor_factory(settings):
    """Get processor factory from settings and return

    """
    resolver = DottedNameResolver()
    processor_factory = settings['billy.processor_factory']
    processor_factory = resolver.maybe_resolve(processor_factory)
    return processor_factory
开发者ID:Imaxinacion,项目名称:billy,代码行数:10,代码来源:utils.py

示例8: init_transistor

# 需要导入模块: from pyramid.path import DottedNameResolver [as 别名]
# 或者: from pyramid.path.DottedNameResolver import maybe_resolve [as 别名]
    def init_transistor(self, **kwargs):
        if kwargs['output'].scheme == 'file' and \
           kwargs['output'].netloc == '-':
            del self.channels['output']
            drain = self.init_stream_drain(**kwargs)
        elif kwargs['output'].scheme.lower() in ZMQ_TRANSPORTS:
            drain = self.init_zmq_drain(**kwargs)
        elif kwargs['output'].scheme == 'kafka':
            del self.channels['output']
            drain = self.init_kafka_drain(**kwargs)
        elif kwargs['output'].scheme == 'sqs':
            del self.channels['output']
            drain = self.init_sqs_drain(**kwargs)
        else:
            raise ValueError(
                'Unsupported drain scheme: {}'.format(kwargs['output'].scheme)
            )

        # The gate "has" a drain;
        # a source "has" a gate
        resolver = DottedNameResolver()
        transducer = resolver.maybe_resolve(kwargs['transducer'])
        if kwargs['transducer_config']:
            transducer = transducer(*kwargs['transducer_config'])
        kwargs['gate'] = Gate(
            self.logger,
            self.loop,
            drain,
            transducer,
        )

        if not kwargs['input'][0].scheme and kwargs['input'][0].path == '-':
            del self.channels['input']
            source = self.init_stream_source(**kwargs)
        elif kwargs['input'][0].scheme == 'file':
            del self.channels['input']
            source = self.init_pailfile_source(**kwargs)
        elif kwargs['input'][0].scheme.lower() in ZMQ_TRANSPORTS:
            source = self.init_zmq_source(**kwargs)
        elif kwargs['input'][0].scheme == 'kafka':
            del self.channels['input']
            source = self.init_kafka_source(**kwargs)
        elif kwargs['input'][0].scheme == 'sqs':
            del self.channels['input']
            source = self.init_sqs_source(**kwargs)
        else:
            raise ValueError(
                'Unsupported source scheme: {}'.format(kwargs['input'].scheme)
            )

        return Transistor(
            self.logger,
            self.loop,
            kwargs['gate'],
            source,
            drain,
        )
开发者ID:CrowdStrike,项目名称:cs.eyrie,代码行数:59,代码来源:actuator.py

示例9: processor

# 需要导入模块: from pyramid.path import DottedNameResolver [as 别名]
# 或者: from pyramid.path.DottedNameResolver import maybe_resolve [as 别名]
    def processor(self):
        """The payment processor

        """
        settings = self.registry.settings
        resolver = DottedNameResolver()
        processor_factory = settings['billy.processor_factory']
        processor_factory = resolver.maybe_resolve(processor_factory)
        processor = processor_factory()
        return processor
开发者ID:JeffersonK,项目名称:billy,代码行数:12,代码来源:request.py

示例10: deserialize

# 需要导入模块: from pyramid.path import DottedNameResolver [as 别名]
# 或者: from pyramid.path.DottedNameResolver import maybe_resolve [as 别名]
 def deserialize(self, node, cstruct):
     if callable(cstruct):
         return cstruct
     elif isinstance(cstruct, str):
         resolver = DottedNameResolver()
         scheduler = resolver.maybe_resolve(cstruct)
         return scheduler
     raise Invalid(node, '{} is not a valid Python dotted name'.format(
         cstruct
     ))
开发者ID:rcommande,项目名称:papaye,代码行数:12,代码来源:settings.py

示例11: list_view

# 需要导入模块: from pyramid.path import DottedNameResolver [as 别名]
# 或者: from pyramid.path.DottedNameResolver import maybe_resolve [as 别名]
def list_view(session, model, columns, **kw):
    """ create list_view imperatively
    
    :param session: session object or dotted_name.
    :param model: model class or dotted_name.
    :param columns: column definitions for :class:`rebecca.helpers.Grid`
    :param kw: additional args for :class:`rebecca.helpers.Grid`
    """

    resolver = DottedNameResolver(caller_package())
    session = resolver.maybe_resolve(session)
    model = resolver.maybe_resolve(model)
    grid = h.Grid(columns, **kw)
    View = type(model.__name__ + '_ListView',
        (ListView,), {})
    View.session = session
    View.model = model
    View.grid = grid
    return View
开发者ID:rebeccaframework,项目名称:rebecca,代码行数:21,代码来源:views.py

示例12: get_api_class

# 需要导入模块: from pyramid.path import DottedNameResolver [as 别名]
# 或者: from pyramid.path.DottedNameResolver import maybe_resolve [as 别名]
def get_api_class(registry):
    """Looks up a the API class to use within a Pyramid configuration registry.
    It will return the TemplateAPI class if none is found.
    """
    api_class = TemplateAPI
    if hasattr(registry, 'settings'):
        api_class_path = registry.settings.get('bowab.api_class', api_class)
        resolver = DottedNameResolver()
        api_class = resolver.maybe_resolve(api_class_path)
    return api_class
开发者ID:sixfeetup,项目名称:sixfeetup.bowab,代码行数:12,代码来源:subscribers.py

示例13: get_pwreset_class

# 需要导入模块: from pyramid.path import DottedNameResolver [as 别名]
# 或者: from pyramid.path.DottedNameResolver import maybe_resolve [as 别名]
def get_pwreset_class(registry):
    """Looks up the password reset class to use within a Pyramid
    configuration registry. It will return the PasswordReset class
    if none is set.
    """
    pwreset_class = PasswordReset
    if hasattr(registry, 'settings'):
        pwreset_class_path = registry.settings.get(
            'speak_friend.pwreset_class', pwreset_class)
        resolver = DottedNameResolver()
        pwreset_class = resolver.maybe_resolve(pwreset_class_path)
    return pwreset_class
开发者ID:sixfeetup,项目名称:speak_friend,代码行数:14,代码来源:events.py

示例14: debug

# 需要导入模块: from pyramid.path import DottedNameResolver [as 别名]
# 或者: from pyramid.path.DottedNameResolver import maybe_resolve [as 别名]
    def debug(self, debugger):
        local = self.repo.local  # noqa
        remote = self.repo.remote  # noqa

        resolve = DottedNameResolver()
        debugger_obj = resolve.maybe_resolve(debugger)
        set_trace = getattr(debugger_obj, 'set_trace', None)
        if not callable(set_trace):
            print('Invalid debugger: {}: using pdb'.format(debugger))
            import pdb
            set_trace = pdb.set_trace
        set_trace()  # DEBUGGING
        pass
开发者ID:TakesxiSximada,项目名称:gaf,代码行数:15,代码来源:flows.py

示例15: includeme

# 需要导入模块: from pyramid.path import DottedNameResolver [as 别名]
# 或者: from pyramid.path.DottedNameResolver import maybe_resolve [as 别名]
def includeme(config):
    """ Configure the app """
    settings = config.get_settings()

    resolver = DottedNameResolver(__name__)
    dotted_name = getdefaults(settings, "pypi.auth", "pypi.access_backend", "config")
    if dotted_name == "config":
        dotted_name = ConfigAccessBackend
    elif dotted_name == "remote":
        dotted_name = RemoteAccessBackend
    elif dotted_name == "sql":
        dotted_name = SQLAccessBackend
    access_backend = resolver.maybe_resolve(dotted_name)
    kwargs = access_backend.configure(settings)
    config.add_request_method(partial(access_backend, **kwargs), name="access", reify=True)
开发者ID:raizyr,项目名称:pypicloud,代码行数:17,代码来源:__init__.py


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