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


Python Configurator.scan方法代码示例

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


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

示例1: app

# 需要导入模块: from pyramid.configuration import Configurator [as 别名]
# 或者: from pyramid.configuration.Configurator import scan [as 别名]
def app(global_config, **settings):
    """ This function returns a ``pyramid`` application object.  It
    is usually called by the PasteDeploy framework during ``paster
    serve``"""
    combined_config = {}
    combined_config.update(global_config)
    combined_config.update(settings)
    setup_model(**combined_config)
    config = Configurator(root_factory=get_root, settings=combined_config)
    config.scan()
    config.add_static_view(name="static", path="spazzer.web:templates/static")
    return config.make_wsgi_app()
开发者ID:twillis,项目名称:spazzer,代码行数:14,代码来源:run.py

示例2: test_scanned

# 需要导入模块: from pyramid.configuration import Configurator [as 别名]
# 或者: from pyramid.configuration.Configurator import scan [as 别名]
 def test_scanned(self):
     from pyramid.interfaces import IRequest
     from pyramid.interfaces import IView
     from pyramid.interfaces import IViewClassifier
     from pyramid.configuration import Configurator
     from pyramid.tests import test_integration
     config = Configurator()
     config.scan(test_integration)
     reg = config.registry
     view = reg.adapters.lookup(
         (IViewClassifier, IRequest, INothing), IView, name='')
     self.assertEqual(view, wsgiapptest)
开发者ID:markramm,项目名称:pyramid,代码行数:14,代码来源:test_integration.py

示例3: make_pyramid_app

# 需要导入模块: from pyramid.configuration import Configurator [as 别名]
# 或者: from pyramid.configuration.Configurator import scan [as 别名]
def make_pyramid_app(global_config, **kwargs):
    """ This function returns a WSGI application.
    """

    settings = dict(global_config)
    settings.update(kwargs)
    config = Configurator(root_factory=get_root,
                          settings=init_settings(global_config))
    config.add_renderer('.html', renderer_factory)
    config.add_static_view('static', 'academe:static')
    config.scan('academe')

    pyramid_app = config.make_wsgi_app()

    return pyramid_app
开发者ID:jcress410,项目名称:academe,代码行数:17,代码来源:__init__.py

示例4: main

# 需要导入模块: from pyramid.configuration import Configurator [as 别名]
# 或者: from pyramid.configuration.Configurator import scan [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    from pyramid.configuration import Configurator
    config = Configurator(settings=settings)
    config.add_renderer(name = 'nt', factory='.renderers.NTriplesGraphRenderer')
    config.add_renderer(name = 'rdfxml', factory='.renderers.RDFXMLGraphRenderer')
    config.add_renderer(name = 'n3', factory='.renderers.N3GraphRenderer')
    
    session_factory = session_factory_from_settings(settings)
    config.set_session_factory(session_factory)
    
    config.registry['sparql.url'] = settings['sparql.url']

    config.add_static_view('static', 'sparql_shim:static/')
    config.add_handler('direct_graph', '/{name:.+}', '.handlers:GraphHandler',
                       action='graph')
    config.add_handler('indirect_graph', '/', '.handlers:GraphHandler',
                       action='graph')
    config.scan('sparql_shim.subscribers')
    return config.make_wsgi_app()
开发者ID:norcalrdf,项目名称:sparql-shim,代码行数:23,代码来源:__init__.py

示例5: home

# 需要导入模块: from pyramid.configuration import Configurator [as 别名]
# 或者: from pyramid.configuration.Configurator import scan [as 别名]
'''
Created on Jun 19, 2012

@author: silviu
'''
from blog.entity.post import loadFirst
from pyramid.configuration import Configurator
from pyramid.renderers import render_to_response
from pyramid.response import Response
from pyramid.static import static_view
from pyramid.view import view_config
from wsgiref.simple_server import make_server

@view_config()
def home(request):
    p = loadFirst()
    return render_to_response('templates/home.pt', 
                              {'project':'blog', 'text': p.text},
                              request=request)

if __name__ == '__main__':
    config = Configurator()
    config.add_route('imageiframe', 'imageiframe/{image}')
    config.scan('blog')
    config.add_static_view('img', 'blog:img');
    config.add_static_view('js', 'blog:js');
    config.add_static_view('css', 'blog:css');
    config.add_static_view('document', 'blog:documents');
    app = config.make_wsgi_app()
    server = make_server('0.0.0.0', 8080, app)
    server.serve_forever()
开发者ID:chronicweirdo,项目名称:parrot_sketch,代码行数:33,代码来源:BlogMain.py


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