本文整理汇总了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()
示例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)
示例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
示例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()
示例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()