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


Python Configurator.add_subscriber方法代码示例

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


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

示例1: main

# 需要导入模块: from pyramid.configuration import Configurator [as 别名]
# 或者: from pyramid.configuration.Configurator import add_subscriber [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator()
    config.begin()
    
    db_uri = settings['db_uri']
    server_url = settings['server_url']
    conn = Connection(db_uri)
    config.registry.settings['db_conn'] = conn
    config.registry.settings['server_url'] = server_url
    config.registry.settings['db_name'] = settings['db_name']
    config.add_subscriber(add_mongo_db, NewRequest)

    config.include('pyramid_zcml')
    config.load_zcml('configure.zcml')
    config.end()

    #add renderer
    #Fixme: try to insert this on zcml file 
    config.add_renderer('jsonp', JSONP(param_name='callback'))
      
    return config.make_wsgi_app()
开发者ID:chiehwen,项目名称:Analytics,代码行数:25,代码来源:__init__.py

示例2: registerSubscriber

# 需要导入模块: from pyramid.configuration import Configurator [as 别名]
# 或者: from pyramid.configuration.Configurator import add_subscriber [as 别名]
def registerSubscriber(subscriber, iface=Interface):
    """ Register a ZCA subscriber component.

    The ``subscriber`` argument specifies the implementation of the
    subscriber component (often a function).

    The ``iface`` argument is the interface type for which the
    subscriber will be registered (:class:`zope.interface.Interface`
    by default). If ``iface`` is not a tuple or list, it will be
    converted to a one-tuple before being passed to the underlying ZCA
    :meth:`pyramid.registry.registerHandler` method.

    See `The ZCA book <http://www.muthukadan.net/docs/zca.html>`_ for
    more information about ZCA subscribers.

    .. warning:: This API is deprecated as of :app:`Pyramid` 1.0.
       Instead use the
       :meth:`pyramid.configuration.Configurator.add_subscriber`
       method in your unit and integration tests.
    """
    registry = get_current_registry()
    config = Configurator(registry)
    return config.add_subscriber(subscriber, iface=iface)
开发者ID:blaflamme,项目名称:pyramid,代码行数:25,代码来源:testing.py


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