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


Python Configurator.registry['mailer']方法代码示例

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


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

示例1: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import registry['mailer'] [as 别名]
def main(global_config, **settings):
    """
    This function returns a Pyramid WSGI application.
    """
    # the database session:
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine

#    session_factory = session_factory_from_settings(settings)
    config = Configurator(
        settings=settings,
        root_factory=get_root,
        authentication_policy=GyAuthenticationPolicy(),
        authorization_policy=GyAuthorizationPolicy(),
        session_factory = session_factory_from_settings(settings),
        request_factory = GyRequest,
    )

    config.add_static_view('static', 'static', cache_max_age=3600)
    
#    config.include('pyramid_mailer')

    mailer = Mailer.from_settings(settings)
    config.registry['mailer'] = mailer

    config.include('gy.core')
    config.include('gy.blog')
    config.add_notfound_view(gy_not_found, append_slash=True)


    config.scan()
    return config.make_wsgi_app()
开发者ID:kratenko,项目名称:gy,代码行数:35,代码来源:__init__.py

示例2: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import registry['mailer'] [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings)
    config.include('pyramid_chameleon')
    config.include('pyramid_mako')
    config.include("cornice")
    config.include('pyramid_mailer')
    config.registry['mailer'] = Mailer.from_settings(settings)
    config_db(config, settings)
    config_routes(config)
    config_auth_policy(config, settings)

    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/home')
    config.scan()

    # Added these lines
    ## Pull in Angular App as python package, must have includeme() in __init__.py
    config.include('app')
    ## These pull along with static.py mount the angular app at /
    config.add_route('catchall_static', '/*subpath')
    config.add_view('server.static.static_view', route_name='catchall_static')

    return config.make_wsgi_app()
开发者ID:neuropoly,项目名称:spinalcordtoolbox_web,代码行数:27,代码来源:__init__.py

示例3: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import registry['mailer'] [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application. """


    config = Configurator(settings=settings)

    #set up beaker session
    session_factory = session_factory_from_settings(settings)
    config.set_session_factory(session_factory)


    # add security tweens
 #   config.add_tween('aws_demo.tweens.clickjacking.clickjacking_factory')
 #   config.add_tween('aws_demo.tweens.secure_headers.secure_headers_factory')

    config.registry['mailer'] = Mailer.from_settings(settings=settings)

    # modify the built in json renderer to serialize dates properly
    json_date_renderer = JSON()
    json_date_renderer.add_adapter(datetime.datetime, new_datetime_adapter)
    
    # set .html renderer to allow mako templating
    config.add_renderer('.html', 'pyramid.mako_templating.renderer_factory')
    config.add_renderer('.htm', 'pyramid.mako_templating.renderer_factory')
    config.add_renderer('json', json_date_renderer)
    
    config.add_static_view('static', 'static', cache_max_age=3600)

    # login / registration
    config.add_route('index_view', '/')


    config.scan()
    return config.make_wsgi_app()
开发者ID:k-wiens,项目名称:Blah,代码行数:36,代码来源:__init__.py

示例4: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import registry['mailer'] [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    authentication_policy = AuthTktAuthenticationPolicy('seekrit', callback=groupfinder)
    authorization_policy = ACLAuthorizationPolicy()

    engine = engine_from_config(settings, prefix='sqlalchemy.')
    db_maker = sessionmaker(bind=engine)
    settings['rel_db.sessionmaker'] = db_maker

    config = Configurator(settings=settings,
                          root_factory='scielobooks.resources.RootFactory',
                          authentication_policy=authentication_policy,
                          authorization_policy=authorization_policy,
                          request_factory=MyRequest,
                          renderer_globals_factory=renderer_globals_factory)

    config.include(pyramid_zcml)
    config.load_zcml('configure.zcml')
    config.include('pyramid_mailer')
    config.include('pyramid_celery')

    config.registry['mailer'] = Mailer.from_settings(settings)
    config.registry['app_version'] = APP_VERSION

    db_uri = settings['db_uri']
    conn = couchdbkit.Server(db_uri)
    config.registry.settings['db_conn'] = conn
    config.add_subscriber(add_couch_db, NewRequest)

    config.scan('scielobooks.models')
    initialize_sql(engine)

    if settings['serve_static_files'] == 'true':
        config.add_static_view(name='static', path='static')
    config.add_static_view('deform_static', 'deform:static')
    config.add_static_view('/'.join((settings['db_uri'], settings['db_name'])), 'scielobooks:database')
    config.add_static_view(settings['fileserver_url'], 'scielobooks:fileserver')

    config.add_view(custom_forbidden_view, context=Forbidden)

    config.add_translation_dirs('scielobooks:locale/')
    config.set_locale_negotiator(custom_locale_negotiator)

    my_session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet')
    config.set_session_factory(my_session_factory)

    application = config.make_wsgi_app()

    try:
        if settings.get('newrelic.enable', 'False').lower() == 'true':
            newrelic.agent.initialize(os.path.join(APP_PATH, '..', 'newrelic.ini'), settings['newrelic.environment'])
            return newrelic.agent.wsgi_application()(application)
        else:
            return application
    except IOError:
        config.registry.settings['newrelic.enable'] = False
        return application
开发者ID:fabiobatalha,项目名称:scielobooks,代码行数:60,代码来源:__init__.py

示例5: __init__

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import registry['mailer'] [as 别名]
    def __init__(self, *args, **settings):
        if len(args) == 1:
            # regular app
            app = None
        else:
            app = args[0]
        self.initialize_settings(app, settings)

        # db configuration
        db_factory_name = settings.get('db_factory_name', 'sql')
        if db_factory_name not in db_factories:
            raise Exception("Invalid db_factory_name: %s" % db_factory_name)
        settings['db_session_id'], self.db = db_factories[db_factory_name](settings, self)  # noqa

        self.setup_autouserfinder(settings)

        # start pyramid application configuration
        config = Configurator(settings=settings, request_factory=Request)
        try:
            import pyramid_chameleon  # noqa
            config.include('pyramid_chameleon')
        except ImportError:
            pass

        self.setup_plugins(config, settings)

        from factored.views import auth_chooser, notfound
        config.add_route('auth', self.base_auth_url)
        config.add_view(auth_chooser, route_name='auth',
                        renderer='templates/layout.pt')

        # setup template customization registration
        if TEMPLATE_CUSTOMIZATIONS not in config.registry:
            config.registry[TEMPLATE_CUSTOMIZATIONS] = {}

        # static paths for resources
        self.static_path = os.path.join(self.base_auth_url, 'authstatic')
        config.add_static_view(name=self.static_path,
                               path='factored:static')
        config.add_notfound_view(notfound, append_slash=True)

        # add some things to registry
        config.registry['mailer'] = Mailer.from_settings(settings)
        config.registry['settings'] = self.__dict__
        config.registry['formtext'] = nested_settings(
            get_settings(settings, 'formtext.'))
        config.registry['app'] = self

        config.scan()
        self.config = config
        self.registry = self.config.registry
        try:
            self.app.config.registry['factored'] = self
        except:
            pass
        self.pyramid = config.make_wsgi_app()
开发者ID:wildcardcorp,项目名称:factored,代码行数:58,代码来源:app.py

示例6: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import registry['mailer'] [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    Base.metadata.reflect(only=('anlicenses', 'pdidx', 'anproducts'))
    config = Configurator(settings=settings)
    config.registry['mailer'] = mailer_factory_from_settings(settings)
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')
    config.scan()
    return config.make_wsgi_app()
开发者ID:igudym,项目名称:webstore,代码行数:15,代码来源:__init__.py

示例7: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import registry['mailer'] [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    l = LoginDAO()
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)    
    Base.metadata.bind = engine
    authn_policy = AuthTktAuthenticationPolicy('sosecret', callback=l.groupfinder, hashalg='sha512')
    authz_policy = ACLAuthorizationPolicy()
    config = Configurator(settings=settings, root_factory="terminus.models.Login")
    config.registry['mailer'] = Mailer.from_settings(settings)
    config.set_session_factory(my_session_factory)
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)
    config.include('pyramid_chameleon')
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')
    #Admin routes
    config.add_route('adm', '/adm')
    config.add_route('clientes', '/adm/clientes')
    config.add_route('gerentes', '/adm/gerentes')
    config.add_route('novoprojeto', '/adm/novoprojeto')
    config.add_route('novogerente', '/adm/novogerente')
    config.add_route('addgerente', '/adm/addgerente')
    config.add_route('editargerente', '/adm/{id}/editargerente')
    config.add_route('deletargerente', '/adm/{id}/deletargerente')
    config.add_route('deletarcliente', '/adm/{id}/deletarcliente')
    config.add_route('atualizargerente', '/adm/atualizargerente')
    config.add_route('novocliente', '/adm/novocliente')
    config.add_route('addcliente', '/adm/addcliente')
    config.add_route('projeto', '/adm/projeto/{pid}/')
    config.add_route('addprojeto', '/adm/addprojeto')
    config.add_route('tarefa', '/adm/projeto/{id}/addtarefa')
    config.add_route('finalizar-tarefa', '/adm/projeto/{id}/finalizar/{status}/{pid}')
    config.add_route("responder-alteracao","adm/{id}/responderalteracao/{pid}")
    config.add_route("configuracoes","/adm/configuracoes")
    config.add_route("cadastro-email","/adm/cadastro-email/")
    config.add_route("atualizar-email","/adm/atualizar-email/")

    #Client routes
    config.add_route('login-gerentes', '/adm/login')
    config.add_route("cliente-index","/{id}/index")
    config.add_route("cliente-dados","/{id}/dados")
    config.add_route("cliente-atualizar","/{id}/atualizarcliente")
    config.add_route("projeto-cliente","/{id}/projeto/{pid}")
    config.add_route("projeto-aprovacao","/{id}/projetoaprovacao/{pid}")
    config.add_route("solicitar-alteracao","/{id}/solicitaralteracao/{pid}")
    config.scan()
    return config.make_wsgi_app()
开发者ID:AlissonMMenezes,项目名称:Terminus,代码行数:51,代码来源:__init__.py

示例8: __init__

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import registry['mailer'] [as 别名]
    def __init__(self, *args, **settings):
        if len(args) == 1:
            # regular app
            app = None
        else:
            app = args[0]
        self.initialize_settings(app, settings)

        # db configuration
        engine = engine_from_config(settings, 'sqlalchemy.')
        configure_db = settings.pop('configure_db', 'true').lower() == 'true'

        if configure_db:
            DBSession.configure(bind=engine)
            self.db_session_id = 'f'
        else:
            self.db_session_id = settings.pop('db_session_id')

        self.setup_autouserfinder(settings)

        # start pyramid application configuration
        config = Configurator(settings=settings, request_factory=Request)

        self.setup_plugins(config, settings)

        from factored.views import auth_chooser, notfound
        config.add_route('auth', self.base_auth_url)
        config.add_view(auth_chooser, route_name='auth',
                        renderer='templates/layout.pt')

        # setup template customization registration
        if TEMPLATE_CUSTOMIZATIONS not in config.registry:
            config.registry[TEMPLATE_CUSTOMIZATIONS] = {}

        # static paths for resources
        self.static_path = os.path.join(self.base_auth_url, 'authstatic')
        config.add_static_view(name=self.static_path,
                               path='factored:static')
        config.add_notfound_view(notfound, append_slash=True)

        # add some things to registry
        config.registry['mailer'] = Mailer.from_settings(settings)
        config.registry['settings'] = self.__dict__
        config.registry['formtext'] = nested_settings(
            get_settings(settings, 'formtext.'))
        config.registry['app'] = self

        config.scan()
        self.pyramid = config.make_wsgi_app()
开发者ID:zombified,项目名称:factored,代码行数:51,代码来源:app.py

示例9: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import registry['mailer'] [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    authentication_policy = AuthTktAuthenticationPolicy('seekrit', callback=groupfinder)
    authorization_policy = ACLAuthorizationPolicy()
    
    engine = engine_from_config(settings, prefix='sqlalchemy.')
    db_maker = sessionmaker(bind=engine)
    settings['rel_db.sessionmaker'] = db_maker

    config = Configurator(settings=settings,
                          root_factory='scielobooks.resources.RootFactory',
                          authentication_policy=authentication_policy,
                          authorization_policy=authorization_policy,
                          request_factory=MyRequest)

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

    config.registry['mailer'] = Mailer.from_settings(settings)

    db_uri = settings['db_uri']
    conn = couchdbkit.Server(db_uri)
    config.registry.settings['db_conn'] = conn
    config.add_subscriber(add_couch_db, NewRequest)
    
    config.scan('scielobooks.models')
    initialize_sql(engine)

    if settings['serve_static_files'] == 'true':
        config.add_static_view(name='static', path='static')
    config.add_static_view('deform_static', 'deform:static')
    config.add_static_view(settings['books_static_url'], 'scielobooks:books')
    config.add_static_view('/'.join((settings['db_uri'], settings['db_name'])), 'scielobooks:database')
    
    config.add_view(custom_forbidden_view, context=Forbidden)

    config.add_translation_dirs('scielobooks:locale/')
    config.set_locale_negotiator(custom_locale_negotiator)

    my_session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet')
    config.set_session_factory(my_session_factory)

    return config.make_wsgi_app()
开发者ID:alvesjnr,项目名称:scielobooks,代码行数:47,代码来源:__init__.py

示例10: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import registry['mailer'] [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    
    # Authentication & authorisation
    authentication_policy = AuthTktAuthenticationPolicy('seekrit', callback=groupfinder)
    authorization_policy = ACLAuthorizationPolicy()
    
    # Sessions
    session_factory = pyramid_beaker.session_factory_from_settings(settings)
    
    config = Configurator(
            root_factory=Root,
            settings=settings,
            authentication_policy=authentication_policy,
            authorization_policy=authorization_policy,
            session_factory=session_factory,
            )

    # Add helpers to render
    config.add_subscriber(add_renderer_globals, BeforeRender)

    # MongoDB related
    db_uri = settings['db_uri']
    conn = pymongo.Connection(db_uri)    
    config.registry.settings['db_conn'] = conn
    config.add_subscriber(add_mongo_db, NewRequest)
    
    # Delete if running in development mode
    if settings['db.reset'] == 'true':
        conn.drop_database(settings['db_name'])
    
    initialize_mongo(conn[settings['db_name']])
    dbupdates.update(conn[settings['db_name']])
    
    # Mailer
    config.include('pyramid_mailer')
    config.registry['mailer'] = Mailer.from_settings(settings)
    
    # CSRF check
    config.add_subscriber(csrf_validation, NewRequest)
    
    config.add_static_view('static', 'formative:static')
    config.scan()
    return config.make_wsgi_app()
开发者ID:circlingthesun,项目名称:Formative,代码行数:47,代码来源:__init__.py

示例11: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import registry['mailer'] [as 别名]
def main(global_config, **settings):
    """ This function returns a WSGI application.
    """
    #engine = engine_from_config(settings, 'sqlalchemy.')
    #DBSession.configure(bind=engine)
    
    config = Configurator(settings=settings, root_factory=RootFactory)
#    config = Configurator(settings=settings)
    #config.add_subscriber(add_renderer_globals, BeforeRender)
    # HTML Rederer
    config.add_renderer('.html', 'pyramid.mako_templating.renderer_factory')
    # Configure Beaker sessions
    #session_factory = UnencryptedCookieSessionFactoryConfig(settings)
    session_factory = pyramid_beaker.session_factory_from_settings(settings)
    print session_factory
    config.set_session_factory(session_factory)
    # Authendication/Autherization
    authn_policy = AuthTktAuthenticationPolicy(
                       settings.get('mool.auth_secret'),
                       #secure = True,
                       http_only = True,
                       callback=group_finder)
    config.set_authentication_policy(authn_policy)

    authz_policy = ACLAuthorizationPolicy()
    config.set_authorization_policy(authz_policy)
    # Request Object With user object
    config.set_request_factory(RequestWithUserAttribute)
    # Pyramid_mailer Configuration 
    config.registry['mailer'] = Mailer.from_settings(settings)

    config.add_view('pyramid.view.append_slash_notfound_view',
                    context='pyramid.httpexceptions.HTTPNotFound')
    config.add_static_view('static', 'mool:static', cache_max_age=360000)
    config.add_route('index', '')
    config.add_route('register.view', '/register/')
    config.add_route('durga_update.view', '/durga_update/')
    config.add_route('durga_find.view', '/durga_find/')
    config.scan('durga.views')

    #Base.metadata.create_all(engine)
    #initialize_connection()
    return config.make_wsgi_app()
开发者ID:nikmural,项目名称:hike_hackathon,代码行数:45,代码来源:__init__.py

示例12: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import registry['mailer'] [as 别名]
def main(global_config, **settings):
    """Returns the Pyramid WSGI application"""
    # Ensure that the production configuration has been updated with "real"
    # values (at least where required for security)
    for key in ('authn.secret', 'session.secret'):
        if settings.get(key) == 'CHANGEME':
            raise ValueError('You must specify a new value for %s' % key)
    mimetypes.init()
    session_factory = session_factory_from_settings(settings)
    mailer_factory = mailer_factory_from_settings(settings)
    licenses_factory = licenses_factory_from_settings(settings)
    authn_policy = authentication_policy_from_settings(settings)
    authz_policy = ACLAuthorizationPolicy()
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)

    config = Configurator(
        settings=settings,
        root_factory=RootContextFactory,
        authentication_policy=authn_policy,
        authorization_policy=authz_policy,
        session_factory=session_factory)
    config.registry['mailer'] = mailer_factory
    config.registry['licenses'] = licenses_factory
    # XXX Deprecated in 1.4
    config.set_request_property(get_user, b'user', reify=True)
    # XXX For 1.4:
    #config.add_request_method(get_user, b'user', reify=True)
    config.add_static_view('static', 'static', cache_max_age=3600)
    for name, url in ROUTES.items():
        if '{collection_id:' in url:
            factory = CollectionContextFactory
        elif '{sample_id:' in url:
            factory = SampleContextFactory
        else:
            factory = RootContextFactory
        config.add_route(name, url, factory=factory)
    config.scan()
    app = config.make_wsgi_app()
    # XXX Dirty horrid hack for functional testing
    if settings.get('testing', '0') == '1':
        app.engine = engine
    return app
开发者ID:gmalik9,项目名称:samplesdb,代码行数:45,代码来源:__init__.py

示例13: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import registry['mailer'] [as 别名]
def main(global_config, **settings):
    """ This function returns a WSGI application.
    """
    # security
    my_session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet')
    whoconfig_file = settings['whoconfig_file']
    identifier_id = 'auth_tkt'
    authn_policy = WhoV2AuthenticationPolicy(whoconfig_file, identifier_id)
    authz_policy = ACLAuthorizationPolicy()    
    
    config = Configurator(root_factory=Root,
                          settings=settings,
                          session_factory = my_session_factory,
                          authentication_policy=authn_policy,
                          authorization_policy=authz_policy)
    
    config.registry['mailer'] = Mailer.from_settings(settings)
    
    config.add_static_view('static', 'saloensenyament:static')
    config.add_static_view('css', 'saloensenyament:css')
    config.add_static_view('images', 'saloensenyament:images')
    config.add_static_view('js', 'saloensenyament:js')
    
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')

    config.add_view('saloensenyament.views.login.login', route_name='login',
                     renderer='saloensenyament:templates/login.pt')
    config.add_view('saloensenyament.views.login.logout', route_name='logout')
    
    config.add_view('saloensenyament.views.login.login',
                    context='pyramid.httpexceptions.HTTPForbidden',
                    renderer='saloensenyament:templates/login.pt')

    config.scan('saloensenyament')


    return config.make_wsgi_app()
开发者ID:UPCnet,项目名称:saloensenyament,代码行数:40,代码来源:__init__.py

示例14: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import registry['mailer'] [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    initialize_sql(engine)

    session_factory = session_factory_from_settings(settings)

    #authn_policy = AuthTktAuthenticationPolicy(
    #                                            '21(*^=s2ws%^~1`~|2JHFG1267fYTsaa1kjgh325URHfa', 
    #                                            callback=groupfinder,
    #                                            cookie_name='authcookie',
    #                                            secure=True,
    #                                            timeout=3600,
    #                                            reissue_time=360,
    #                                           )
    authn_policy = SessionAuthenticationPolicy(
                                                callback=groupfinder,
                                                #debug=True,
                                              )
    authz_policy = ACLAuthorizationPolicy()

    config = Configurator(
        settings=settings,
        root_factory=RootFactory,
        authentication_policy=authn_policy,
        authorization_policy=authz_policy,
        introspection=False
        )

    config.registry['mailer'] = mailer_factory_from_settings(settings)
    config.set_session_factory(session_factory)

    config.set_locale_negotiator(locale_negotiator)

    #this add a ".user" property to the request object and run
    #"get_user" internal functions only when assigned to a variable 
    #to get the user data: "user = request.user"
    config.set_request_property(get_user, 'user', reify=True)

    config.add_subscriber('myproject.subscribers.add_renderer_globals',
                          'pyramid.events.BeforeRender')
    #config.add_subscriber('myproject.subscribers.add_localizer',
    #                      'pyramid.events.NewRequest')
    #config.add_subscriber('myproject.subscribers.csrf_validation_event',
    #                      'pyramid.events.NewRequest')
    config.add_subscriber('myproject.subscribers.new_request',
                          'pyramid.events.NewRequest')

    config.add_translation_dirs('myproject:locale')

    #config.add_static_view('captcha_imgs', 'myproject:captcha_imgs')
    #config.add_static_view('static-deform', 'deform:static')
    #config.add_static_view('static', 'myproject:static')
    config.add_static_view(name='http://cdn.mumberla.com/static', path='myproject:static')
    #config.add_static_view('static', 'myproject:static', cache_max_age=3600)

    #config.include('deform_bootstrap')

    config.add_route('home', '/')
    config.add_route('login', '/login')
    config.add_route('signup', '/signup')
    config.add_route('captcha-img', '/captcha-img/{captcha_image}')
    config.add_route('logout', '/logout')

    config.add_route('users', '/users', factory=UserFactory)
    config.add_route('user', '/user/{login}', factory=UserFactory, traverse='/{login}')
    config.add_route('support-key', '/support-key/{username}/{key}')
    config.add_route('support-pwd', '/support-pwd/{username}/{key}')
    config.add_route('change-locale', '/support-loc/{locale}')
   
    config.add_route('dids', '/dids', factory=UserFactory)
    
    config.add_route('twitter_login', '/twitter/login')
    config.add_route('twitter_process', '/twitter/process')
    
    config.add_route('agile_sms', '/agile/post')
    config.add_route('speak', '/speak')
    config.add_route('call', '/call')
    config.add_route('chat', '/chat')

    config.add_route('pages', '/pages', factory=PageFactory)
    config.add_route('create_page', '/create_page', factory=PageFactory)
    config.add_route('page', '/page/{title}', factory=PageFactory, traverse='/{title}')
    #config.add_route('page', '/page/{title}', factory=PageFactory)
    config.add_route('edit_page', '/page/{title}/edit', factory=PageFactory, traverse='/{title}')
    #config.add_route('edit_page', '/page/{title}/edit', factory=PageFactory)
    
    #config.add_static_view('static', 'myproject:static', cache_max_age=3600)

    #config.add_route('main_view', '/')
    #config.add_view('myproject.views.main_view', route_name='main_view')
    
    #config.add_route('login', '/login')
    #config.add_view('myproject.views.login', 
    #                context='pyramid.httpexceptions.HTTPForbidden',
    #                renderer='myproject:templates/login.pt') 
    #config.add_view('myproject.views.login', route_name='login',
    #                renderer='myproject:templates/login.pt') 
    
#.........这里部分代码省略.........
开发者ID:fabiobalzano,项目名称:webradio,代码行数:103,代码来源:__init__.py

示例15: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import registry['mailer'] [as 别名]
def main(global_config, **settings):
    "Returns the Pyramid WSGI application"

    # Ensure we're not using production.ini verbatim
    for key in (
            'site.store',
            'session.secret',
            'login.google.consumer_key',
            'login.google.consumer_secret',
            'login.facebook.consumer_key',
            'login.facebook.consumer_secret',
            'login.twitter.consumer_key',
            'login.twitter.consumer_secret',
            'login.github.consumer_key',
            'login.github.consumer_secret',
            ):
        if settings.get(key) == 'CHANGEME':
            raise ValueError('You must specify a new value for %s' % key)

    # Ensure path is configured appropriately
    files_dir = os.path.normpath(os.path.expanduser(settings['site.files']))
    licenses_dir = os.path.normpath(os.path.expanduser(settings['licenses.cache_dir']))
    check_path(settings['site.files'])
    check_path(settings['licenses.cache_dir'])

    session_factory = session_factory_from_settings(settings)
    mailer_factory = mailer_factory_from_settings(settings)
    licenses_factory = licenses_factory_from_settings(settings)
    engine = engine_from_config(settings, 'sqlalchemy.')

    # Configure the database session; the session is deliberately separated
    # from the model to enable us to bind it to an engine before importing
    # the model which will then use the bound engine to reflect the database
    from .db_session import DBSession
    DBSession.configure(bind=engine, info={'site.files': files_dir})

    from .security import RequestWithUser, group_finder
    config = Configurator(
            settings=settings,
            session_factory=session_factory,
            request_factory=RequestWithUser,
            )
    if settings.get('login.google.consumer_key'):
        config.include('velruse.providers.google_oauth2')
        config.add_google_oauth2_login_from_settings(prefix='login.google.')
    if settings.get('login.facebook.consumer_key'):
        config.include('velruse.providers.facebook')
        config.add_facebook_login_from_settings(prefix='login.facebook.')
    if settings.get('login.twitter.consumer_key'):
        config.include('velruse.providers.twitter')
        config.add_twitter_login_from_settings(prefix='login.twitter.')
    if settings.get('login.github.consumer_key'):
        config.include('velruse.providers.github')
        config.add_github_login_from_settings(prefix='login.github.')
    config.include('pyramid_chameleon')
    # XXX Need some way of grabbing the authentication secret from config
    authn_policy = AuthTktAuthenticationPolicy(
        'secret', hashalg='sha512', callback=group_finder)
    authz_policy = ACLAuthorizationPolicy()
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)
    config.registry['mailer'] = mailer_factory
    config.registry['licenses'] = licenses_factory
    config.add_static_view('static', 'static', cache_max_age=3600)

    from .views.comics import routes as comic_routes
    from .views.admin import routes as admin_routes
    from .security import (
        RootContextFactory,
        ComicContextFactory,
        IssueContextFactory,
        PageContextFactory,
        )
    for name, pattern in comic_routes() + admin_routes():
        if '{page' in pattern:
            factory = PageContextFactory
        elif '{issue' in pattern:
            factory = IssueContextFactory
        elif '{comic' in pattern:
            factory = ComicContextFactory
        else:
            factory = RootContextFactory
        config.add_route(name, pattern, factory=factory)
    config.scan()

    return config.make_wsgi_app()
开发者ID:waveform80,项目名称:ratbot,代码行数:88,代码来源:__init__.py


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