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


Python Configurator.add_handler方法代码示例

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


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

示例1: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_handler [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
    config = Configurator(settings=settings)
    #config.scan()
    config.include('pyramid_handlers')
    config.include('pyramid_chameleon')
    config.add_static_view('static', 'static', cache_max_age=3600)
    
    #home URL's
    config.add_handler('home', '/', handler= ProjectorHome, action='index')
    
    #companies URL's
    config.add_handler('companies_index', '/companies', handler= ProjectorCompanies, action='index')
    config.add_handler('companies_indexm', '/companies/m={m}', handler= ProjectorCompanies, action='index') 
    config.add_handler('companies_indexe', '/companies/e={e}', handler= ProjectorCompanies, action='index')
    config.add_handler('companies_action', '/companies/{action}', handler= ProjectorCompanies)
    config.add_handler('companies_action_id', '/companies/{action}/{id}', handler= ProjectorCompanies)
    #users URL's
    #config.add_handler('users_index','/users', handler = ProjectorUsers, action = 'index')
    #config.add_handler('users_indexm','/users/m={m}', handler = ProjectorUsers, action = 'index')
    #config.add_handler('users_indexe','/users/e={e}', handler = ProjectorUsers, action = 'index')
    #config.add_handler('users_action', '/users/{action}', handler = ProjectorUsers)
    #config.add_handler('users_action_id','/users/{action}/{id}', handler = ProjectorUsers)
    
    return config.wake_wsgi_app()
开发者ID:adagiosci,项目名称:einvoices,代码行数:31,代码来源:__init__back+falla.py

示例2: main

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

    # Initialize database
    pyramid_sqla.add_engine(settings, prefix='sqlalchemy.', 
        convert_unicode=True)

    # Configure Beaker sessions
    session_factory = pyramid_beaker.session_factory_from_settings(settings)
    config.set_session_factory(session_factory)

    # Configure renderers
    config.add_renderer('.html', 'pyramid.mako_templating.renderer_factory')
    config.add_subscriber('simpledemo.subscribers.add_renderer_globals',
                          'pyramid.events.BeforeRender')

    # Set up routes and views
    config.add_handler('home', '/', 'simpledemo.handlers:MainHandler',
                       action='index')
    config.add_handler('main', '/{action}', 'simpledemo.handlers:MainHandler',
        path_info=r'/(?!favicon\.ico|robots\.txt|w3c)')
    add_static_route(config, 'simpledemo', 'static', cache_max_age=3600)

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

示例3: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_handler [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings)
    config.include('pyramid_chameleon')
    config.include('pyramid_handlers')
    config.add_static_view('static', 'static', cache_max_age=3600)
    # config.add_route('home', '/')
    # config.add_route('home_2', '/no_place_like_home/{home_town}')

    config.add_handler('home', '/',
	handler=HomeController, action='index')

    config.add_handler('posts_home_noslash', '/posts',
	handler=PostsController, action='index')
    config.add_handler('posts_home', '/posts/',
	handler=PostsController, action='all')

    config.add_handler('posts_act', '/posts/{action}', handler=PostsController)

    config.add_handler('posts_id', '/posts/{action}/{id}',
	     handler=PostsController)



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

示例4: main

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

    config = Configurator(settings=settings)
    config.include('pyramid_handlers')
    config.include('pyramid_jinja2')
    config.include('pyramid_mailer')

    session_factory = session_factory_from_settings(settings)
    config.set_session_factory(session_factory)

    config.add_directive('add_magic_handler', add_magic_handler)
    config.add_subscriber(add_renderer_globals, BeforeRender)
    config.add_static_view('statics', 'blog:statics')

    # Home route
    config.add_handler('home', get_route(), get_handler('blog'), 'index')

    # Custom routes


    # Index/Action routes
    config.add_magic_handler('user')
    config.add_magic_handler('post')
    config.add_magic_handler('tag')


    return config.make_wsgi_app()
开发者ID:jbcnrlz,项目名称:pyramid-blog,代码行数:33,代码来源:__init__.py

示例5: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_handler [as 别名]
def main(global_config, **settings):
    """ 
        This function returns a Pyramid WSGI application.
    """
    # Configure our authorisation policy
    authn_policy = SaaSAuthTktAuthenticationPolicy(settings)
    authz_policy = UserAuthorizationPolicy()

    engine = engine_from_config(settings, "sqlalchemy.")
    DBSession.configure(bind=engine)
    config = Configurator(
        settings=settings,
        root_factory="viper.handlers.auth.RootFactory",
        authentication_policy=authn_policy,
        authorization_policy=authz_policy,
    )

    config.set_request_property(get_user, "user", reify=True)
    config.include("pyramid_jinja2")
    config.include("pyramid_handlers")

    config.add_renderer("json", json_renderer)

    # config.add_translation_dirs('viper:locale/')

    # from viper.handlers.auth import forbidden
    # config.add_forbidden_view(forbidden)
    config.add_tween("viper.library.security.auth_tween_factory")

    # config.add_subscriber("simpleauth.subscribers.create_url_generator",       "pyramid.events.ContextFound")

    # simpleauth additions
    config.add_handler("login", "/login", "viper.handlers.auth:Auth", action="login")
    config.add_handler("logout", "/logout", "viper.handlers.auth:Auth", action="logout")

    # tenant controller
    config.include("viper.handlers.admin")
    config.include("viper.handlers.tenant")
    config.include("viper.handlers.user")
    config.include("viper.handlers.stock")
    config.include("viper.handlers.invoice")
    config.include("viper.handlers.customer")
    config.include("viper.handlers.supplier")
    config.include("viper.handlers.reports")

    CacheManager.Clear()

    config.add_static_view("static", "static", cache_max_age=3600)
    config.add_route("index", "/")
    config.add_route("home", "/")
    config.include(sales.includeme)
    config.scan()
    return config.make_wsgi_app()
开发者ID:cackharot,项目名称:viper-pos,代码行数:55,代码来源:__init__.py

示例6: main

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

   
    config.set_session_factory(my_session_factory)
    config.include('pyramid_chameleon')
    config.include('pyramid_handlers')
    config.add_handler('dbConnect', '/dbConnect/index',
                   handler='myproject.dbConnect', action='index')
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')

    config.add_route('order','/order.php')
    config.add_route('signin','/signin.php')
    #config.add_handler('dbConnect', '/dbConnect/index', action='index', handler='myproject.controllers.dbConnect')
    config.add_route('about','/about.php')

    config.add_route('hosts','/hosts.php')

    config.add_route('users','/users.php')

    config.add_route('footer','/footer.php')

    config.add_route('success','/success.php')

    config.add_route('checkout','/checkout.php')

    config.add_route('edithost','/edithost.php')

    config.add_route('editinfo','/editinfo.php')

    config.add_route('recovery','/recovery.php')

    config.add_route('settings','/settings.php')


    config.add_route('volunteer','/volunteer.php')
    config.add_route('changepass','/changepass.php')


    config.add_route('infosuccess','/infosuccess.php')

    config.add_route('ordersuccess','/ordersuccess.php')

 

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

示例7: main

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

    config = Configurator(settings=settings)
    config.include('pyramid_chameleon')
    config.include('pyramid_handlers')
    config.add_static_view('static', 'static', cache_max_age=3600)
    # config.add_route('home', '/')
    # config.add_notfound_view(not_found_there)

    config.add_handler('slash', '/', handler=home.HomeController, action='index')
    add_routes(home.HomeController, 'home', config)
    add_routes(admin.AdminController, 'admin', config)
    add_routes(api.ApiController, 'api', config)
    # add_routes(account.AccountController, 'account')


    config.scan()

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

示例8: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_handler [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    here = os.path.dirname(os.path.abspath(__file__))
    settings['mako.directories'] = os.path.join(here, 'templates')
    Base.metadata.bind = engine
    config = Configurator(settings=settings)
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.include('pyramid_handlers')
    config.scan()
    config.add_handler('account', 'account/{action}', handler=Account)
    config.add_handler('item', 'item/{action}', handler=Item)
    config.add_handler('comment', 'comment/{action}', handler=CommentController)
    config.add_handler('home', '/', handler=Home, action='index')
    cb = Couchbase(settings['couchbase.host'], settings['couchbase.bucket'], settings['couchbase.password'])[settings['couchbase.bucket']]
    models.couchbase = cb
    s3 = S3Connection(settings['aws.access_key'], settings['aws.secret_key'])
    models.s3 = s3
    return config.make_wsgi_app()
开发者ID:tomzilla,项目名称:gleebox,代码行数:23,代码来源:__init__.py

示例9: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_handler [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engines = list()
    engines.append(engine_from_config(settings, 'sqlalchemy.'))
    the_root = appmaker(engines)
    session_factory = session_factory_from_settings(settings)
    config = Configurator(settings=settings, root_factory=the_root)
    config.set_session_factory(session_factory)
    config.include('pyramid_handlers')
    config.include('pyramid_mailer')
    config.add_handler("default", "/", action="home",
                       handler="bartervegastech.views.handlers.PageHandler")
    config.add_handler("account", "/account", action="account",
                       handler="bartervegastech.views.handlers.UserAccountHandler")
    config.add_handler("user", "/user/{action}*id",
                       handler="bartervegastech.views.handlers.UserAccountHandler", traverse='/user')
    config.add_handler("pages", "/{action}*id", 
                        handler="bartervegastech.views.handlers.PageHandler")
    config.scan()
    return config.make_wsgi_app()
开发者ID:JustFingDoit,项目名称:bartervegastech,代码行数:23,代码来源:__init__.py

示例10: main

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

    config.include('pyramid_handlers')

    # Initialize database
    engine = pyramid_sqla.add_engine(settings, prefix='sqlalchemy.')
    initialize_sql(engine)

    # Configure Beaker sessions
    session_factory = pyramid_beaker.session_factory_from_settings(settings)
    config.set_session_factory(session_factory)

    # Configure renderers
    config.add_renderer('.html', 'pyramid_jinja2.renderer_factory')
    config.add_subscriber('simplesite.subscribers.add_renderer_globals',
                          'pyramid.events.BeforeRender')

    # Set up routes and views
    config.add_handler('home', '/', 'simplesite.handlers:MainHandler',
                       action='index')
    
    config.add_handler('add', '/submit/', 'simplesite.handlers:MainHandler',
                       action='submit')

    config.add_handler('edit', '/edit/{item_id}/', 
                       'simplesite.handlers:MainHandler',
                       action='edit')


    config.add_handler('main', '/{action}', 'simplesite.handlers:MainHandler',
        path_info=r'/(?!favicon\.ico|robots\.txt|w3c)')
    add_static_route(config, 'simplesite', 'static', cache_max_age=3600)

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

示例11: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_handler [as 别名]
def main(global_config, **settings):
    '''Main config function'''
    Form.set_default_renderer(mako_renderer)
    initializeDb(engine(DbConfig))
    config = Configurator(settings=settings,
                          root_factory=SiteModel)

    config.add_static_view(name='static', path='studentunderground:static')

    #Includes
    config.include('pyramid_handlers')
    config.include('pyramid_tm')
    
    #Handler Root Routes
    config.add_handler('site_root', '/', handler=SiteHandler, action='index')
    config.add_handler('article_root', '/articles', handler=ArticleHandler, action='index')
    config.add_handler('assignment_root', '/assignments', handler=AssignmentHandler, action='index')
    config.add_handler('group_root', '/groups', handler=GroupHandler, action='index')
    config.add_handler('hw_root', '/hw', handler=HwHandler, action='index')
    config.add_handler('setting_root', '/settings', handler=SettingHandler, action='index')
    config.add_handler('user_root', '/user', handler=UserHandler, action='index')

    #Handler Action Routes
    config.add_handler('site_action', '/{action}', handler=SiteHandler)
    config.add_handler('article_action', '/articles/{action}', handler=ArticleHandler)
    config.add_handler('assignment_action', '/assignments/{action}', handler=AssignmentHandler)
    config.add_handler('group_action', '/groups/{action}', handler=GroupHandler)
    config.add_handler('hw_action', '/hw/{action}', handler=HwHandler)
    config.add_handler('setting_action', '/settings/{action}', handler=SettingHandler)
    config.add_handler('user_action', '/user/{action}', handler=UserHandler)
    
    #Exception Views
    config.add_view(notFound,
                    context=NotFound,
                    permission='__no_permission_required__',
                    renderer='exceptions/not_found.mako')
    config.add_view(forbidden,
                    context=Forbidden,
                    permission='__no_permission_required__')

    return config.make_wsgi_app()
开发者ID:jayd3e-archive,项目名称:StudentUnderground,代码行数:43,代码来源:__init__.py

示例12: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_handler [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    
    authn_policy = AuthTktAuthenticationPolicy('session_id', 
        callback=groupfinder
    )
    authz_policy = ACLAuthorizationPolicy()
    
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    config = Configurator(
        settings=settings,
        root_factory=RootFactory,
        authentication_policy=authn_policy,
        authorization_policy=authz_policy,
    )
    #config.scan()
    config.include('pyramid_handlers')
    config.include('pyramid_chameleon')
    config.add_static_view('static', 'static', cache_max_age=3600)
    
    #login URL's
    config.add_handler('main_login', '/main/login', handler= Main, action='login')
    config.add_handler('main_logout', '/main/logout', handler= Main, action='logout')
    #home URL's
    config.add_handler('home', '/', handler= ProjectorHome, action='index')
    
    #users URL's
    config.add_handler('users_index','/users', handler = ProjectorUsers, action='index')
    config.add_handler('users_indexm','/users/m={m}', handler = ProjectorUsers, action = 'index')
    config.add_handler('users_indexe', '/users/e={e}', handler = ProjectorUsers, action = 'index')
    config.add_handler('users_action','/users/{action}', handler = ProjectorUsers)
    config.add_handler('users_action_id','/users/{action}/{id}', handler = ProjectorUsers)
    
    #clients URL's
    config.add_handler('clients_index','/clients', handler = ProjectorClientes, action='index')
    config.add_handler('clients_indexm','/clients/m={m}', handler = ProjectorClientes, action = 'index')
    config.add_handler('clients_indexe', '/clients/e={e}', handler = ProjectorClientes, action = 'index')
    config.add_handler('clients_action','/clients/{action}', handler = ProjectorClientes)
    config.add_handler('clients_action_id','/clients/{action}/{id}', handler = ProjectorClientes)
    
    #companies URL's
    config.add_handler('companies_index', '/companies', handler= ProjectorCompanies, action='index')
    config.add_handler('companies_indexm', '/companies/m={m}', handler= ProjectorCompanies, action='index') 
    config.add_handler('companies_indexe', '/companies/e={e}', handler= ProjectorCompanies, action='index')
    config.add_handler('companies_action', '/companies/{action}', handler= ProjectorCompanies)
    config.add_handler('companies_action_id', '/companies/{action}/{id}', handler= ProjectorCompanies)
    
    #unidades URL's
    config.add_handler('unidades_index','/unidades', handler = ProjectorUnidades, action='index')
    config.add_handler('unidades_indexm','/unidades/m={m}', handler = ProjectorUnidades, action = 'index')
    config.add_handler('unidades_indexe', '/unidades/e={e}', handler = ProjectorUnidades, action = 'index')
    config.add_handler('unidades_action','/unidades/{action}', handler = ProjectorUnidades)
    config.add_handler('unidades_action_id','/unidades/{action}/{id}', handler = ProjectorUnidades)
    
    #suppliers URL's
    #companies URL's
    config.add_handler('suppliers_index', '/suppliers', handler= ProjectorSuppliers, action='index')
    config.add_handler('suppliers_indexm', '/suppliers/m={m}', handler= ProjectorSuppliers, action='index') 
    config.add_handler('suppliers_indexe', '/suppliers/e={e}', handler= ProjectorSuppliers, action='index')
    config.add_handler('suppliers_action', '/suppliers/{action}', handler= ProjectorSuppliers)
    config.add_handler('suppliers_action_id', '/suppliers/{action}/{id}', handler= ProjectorSuppliers)
    
    #sucursales
    config.add_handler('sucursales_index', '/sucursales', handler= ProjectorSucursales, action='index')
    config.add_handler('sucursales_indexm', '/sucursales/m={m}', handler= ProjectorSucursales, action='index') 
    config.add_handler('sucursales_indexe', '/sucursales/e={e}', handler= ProjectorSucursales, action='index')    
    config.add_handler('sucursales_action', '/sucursales/{action}', handler= ProjectorSucursales)
    config.add_handler('sucursales_action_id', '/sucursales/{action}/{id}', handler= ProjectorSucursales)

    #monedas
    config.add_handler('monedas_index', '/monedas', handler= ProjectorMonedas, action='index')
    config.add_handler('monedas_indexm', '/monedas/m={m}', handler= ProjectorMonedas, action='index') 
    config.add_handler('monedas_indexe', '/monedas/e={e}', handler= ProjectorMonedas, action='index')    
    config.add_handler('monedas_action', '/monedas/{action}', handler= ProjectorMonedas)
    config.add_handler('monedas_action_id', '/monedas/{action}/{id}', handler= ProjectorMonedas)

    #bancos
    config.add_handler('bancos_index', '/bancos', handler= ProjectorBancos, action='index')
    config.add_handler('bancos_indexm', '/bancos/m={m}', handler= ProjectorBancos, action='index') 
    config.add_handler('bancos_indexe', '/bancos/e={e}', handler= ProjectorBancos, action='index')    
    config.add_handler('bancos_action', '/bancos/{action}', handler= ProjectorBancos)
    config.add_handler('bancos_action_id', '/bancos/{action}/{id}', handler= ProjectorBancos) 

    #cuenta bancaria
    config.add_handler('cuentabanc_index', '/cuentasbancarias', handler= ProjectorCuentasBancarias, action='index')
    config.add_handler('cuentabanc_indexm', '/cuentasbancarias/m={m}', handler= ProjectorCuentasBancarias, action='index') 
    config.add_handler('cuentabanc_indexe', '/cuentasbancarias/e={e}', handler= ProjectorCuentasBancarias, action='index')    
    config.add_handler('cuentabanc_action', '/cuentasbancarias/{action}', handler= ProjectorCuentasBancarias)
    config.add_handler('cuentabanc_action_id', '/cuentasbancarias/{action}/{id}', handler= ProjectorCuentasBancarias)          
       
    return config.make_wsgi_app()
开发者ID:adagiosci,项目名称:einvoices,代码行数:96,代码来源:__init__.py

示例13: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_handler [as 别名]
def main(global_config, **settings):
    """
    This function returns a Pylons WSGI application.
    """
    from paste.deploy.converters import asbool
    from pyramid.config import Configurator
    from gateway.models import initialize_sql
    from gateway.security import groupfinder

    db_string = settings.get('db_string')
    if db_string is None:
        raise ValueError("No 'db_string' value in application "
                         "configuration.")
    initialize_sql(db_string, asbool(settings.get('db_echo')))
    authn_policy = AuthTktAuthenticationPolicy(
        'sosecret', callback=groupfinder)
    authz_policy = ACLAuthorizationPolicy()

    config = Configurator(settings=settings,
                          autocommit=True,
                          root_factory='gateway.security.RootFactory',
                          authentication_policy=authn_policy,
                          authorization_policy=authz_policy)
    config.begin()
    session_factory = session_factory_from_settings(settings)
    config.include(pyramid_handlers.includeme)
    config.set_session_factory(session_factory)

    config.add_static_view('static', 'gateway:static/')
    config.include('pyramid_mailer')

    config.add_view(view='gateway.handlers.forbidden_view',
                    renderer='forbidden.mako',
                    context=Forbidden)

    config.add_view(view='gateway.handlers.not_found',
                    context=NotFound)

    config.add_route('add',
                     '/add/{class}',
                     renderer='add.mako',
                     permission='admin',
                     view='gateway.handlers.AddClass')

    config.add_route('delete',
                     '/delete/jobs',
                     permission='view',
                     view='gateway.handlers.DeleteJobs')

    config.add_route('edit',
                     '/edit/{class}/{id}',
                     renderer='edit.mako',
                     permission='admin',
                     view='gateway.handlers.EditModel',)

    config.add_route('index',
                     '/',
                     renderer='index.mako',
                     view='gateway.handlers.Index')

    config.add_handler('twilio',
                       'twilio/{action}',
                       handler='gateway.handlers:TwilioHandler')

    config.add_handler('alerts',
                       '/alerts/{action}',
                       'gateway.handlers:AlertHandler')

    config.add_handler('dashboard', '/dashboard',
                       'gateway.handlers:Dashboard',
                       action='index')

    config.add_handler('main', '/:action',
                      handler='gateway.handlers:Dashboard')

    config.add_handler('manage', '/manage/:action',
                       handler='gateway.handlers:ManageHandler')

    config.add_handler('interfaces', '/interface/:action/:id',
                       handler='gateway.handlers:InterfaceHandler'),

    config.add_handler('export-load', 'system/:action',
                       handler='gateway.sys:ExportLoadHandler')

    config.add_handler('users', 'user/:action',
                       handler='gateway.handlers:UserHandler')

    config.add_handler('meter', 'meter/:action/:id',
                       handler='gateway.handlers:MeterHandler')

    config.add_handler('circuit', 'circuit/:action/:id',
                       handler='gateway.handlers:CircuitHandler')

    config.add_handler('logs', 'logs/:action/:meter/',
                       handler='gateway.handlers:LoggingHandler')

    config.add_handler('jobs', 'jobs/:action/:id/',
                       handler='gateway.handlers:JobHandler')

    config.add_handler('sms', 'sms/:action',
#.........这里部分代码省略.........
开发者ID:SEL-Columbia,项目名称:gateway,代码行数:103,代码来源:__init__.py

示例14: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_handler [as 别名]
def main(global_config, **settings):
    """
    This function returns a Pylons WSGI application.
    """
    from paste.deploy.converters import asbool
    from pyramid.config import Configurator
    from gateway.models import initialize_sql
    from gateway.security import groupfinder

    db_string = settings.get('db_string')
    if db_string is None:
        raise ValueError("No 'db_string' value in application "
                         "configuration.")
    initialize_sql(db_string, asbool(settings.get('db_echo')))
    authn_policy = AuthTktAuthenticationPolicy(
        'sosecret', callback=groupfinder)
    authz_policy = ACLAuthorizationPolicy()

    config = Configurator(settings=settings,
                          autocommit=True,
                          root_factory='gateway.models.RootFactory',
                          authentication_policy=authn_policy,
                          authorization_policy=authz_policy)
    config.begin()
    session_factory = session_factory_from_settings(settings)
    config.include(pyramid_handlers.includeme)
    config.set_session_factory(session_factory)

    config.add_static_view('static', 'gateway:static/')
    config.add_static_view('deform-static', 'deform:static')

    config.add_handler('dashboard', '/',
                       'gateway.handlers:Dashboard',
                       action='index')
    config.add_handler('main', '/:action',
                      handler='gateway.handlers:Dashboard')
    config.add_handler('manage', '/manage/:action',
                       handler='gateway.handlers:ManageHandler')
    config.add_handler('interfaces', '/interface/:action/:id',
                       handler='gateway.handlers:InterfaceHandler'),
    config.add_handler('export-load', 'sys/:action',
                       handler='gateway.sys:ExportLoadHandler')
    config.add_handler('users', 'user/:action',
                      handler='gateway.handlers:UserHandler')
    config.add_handler('meter', 'meter/:action/:slug',
                       handler='gateway.handlers:MeterHandler')
    config.add_handler('circuit', 'circuit/:action/:id',
                       handler='gateway.handlers:CircuitHandler')
    config.add_handler('logs', 'logs/:action/:meter/:circuit/',
                       handler='gateway.handlers:LoggingHandler')
    config.add_handler('jobs', 'jobs/:action/:id/',
                       handler='gateway.handlers:JobHandler')
    config.add_handler('sms', 'sms/:action',
                       handler='gateway.handlers:SMSHandler')
    config.add_handler('message', 'message/:action/:id',
                       handler='gateway.handlers:MessageHandler')
    config.add_handler('account', 'account/:action/:id',
                       handler='gateway.handlers:AccountHandler')
    config.add_handler('token', 'token/:action/:id',
                       handler='gateway.handlers:TokenHandler')
    config.add_subscriber('gateway.subscribers.add_renderer_globals',
                          'pyramid.events.BeforeRender')
    config.end()
    return config.make_wsgi_app()
开发者ID:iwillig,项目名称:gateway,代码行数:66,代码来源:__init__.py

示例15: main

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

    file = config.get_settings().get('db_file')
    file = os.path.abspath(file)
    print(file)

    config.include('pyramid_chameleon')
    config.include('pyramid_handlers')
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('rest', '/rest')

    config.add_handler('root', '/', handler=home.HomeController, action='index')
    config.add_handler('home_ctrl_bare', '/home/{action}', handler=home.HomeController)
    config.add_handler('home_ctrl', '/home/{action}/{id}', handler=home.HomeController)

    config.add_handler('posts_ctrl', '/posts/{action}/{id}', handler=posts.PostsController)

    config.add_handler('admin_ctrl_root', '/admin', handler=admin.AdminController, action='index')
    config.add_handler('admin_ctrl_root/', '/admin/', handler=admin.AdminController, action='index')
    config.add_handler('admin_ctrl', '/admin/{action}', handler=admin.AdminController)

    config.add_handler('api_ctrl', '/api/{action}', handler=api.ApiController)

    config.scan()

    DbSessionFactory.global_init()

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


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