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()
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)