本文整理汇总了Python中tg.configuration.AppConfig类的典型用法代码示例。如果您正苦于以下问题:Python AppConfig类的具体用法?Python AppConfig怎么用?Python AppConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AppConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, folder, values=None):
if values is None:
values = {}
AppConfig.__init__(self)
#First we setup some base values that we know will work
self.renderers = ['genshi', 'mako', 'jinja','json']
if not PY3:
self.renderers.extend(['chameleon_genshi', 'kajiki'])
self.render_functions = tg.util.Bunch()
self.package = tests.test_stack
self.default_renderer = 'genshi'
self.globals = self
self.auth_backend = None
self.auto_reload_templates = False
self.use_legacy_renderer = False
self.use_dotted_templatenames = False
self.serve_static = False
root = os.path.dirname(os.path.dirname(tests.__file__))
test_base_path = os.path.join(root,'tests', 'test_stack',)
test_config_path = os.path.join(test_base_path, folder)
self.paths=tg.util.Bunch(
root=test_base_path,
controllers=os.path.join(test_config_path, 'controllers'),
static_files=os.path.join(test_config_path, 'public'),
templates=[os.path.join(test_config_path, 'templates')],
i18n=os.path.join(test_config_path, 'i18n')
)
# then we override those values with what was passed in
for key, value in values.items():
setattr(self, key, value)
示例2: test_mixed_controller_wrapper
def test_mixed_controller_wrapper(self):
milestones._reset_all()
class RootController(TGController):
@expose()
def test(self):
return 'HI!'
app_wrapper_has_been_visited = []
def app_controller_wrapper(app_config, caller):
def call(*args, **kw):
app_wrapper_has_been_visited.append(True)
return caller(*args, **kw)
return call
wrapper_has_been_visited = []
def controller_wrapper(app_config, caller):
def call(*args, **kw):
wrapper_has_been_visited.append(True)
return caller(*args, **kw)
return call
conf = AppConfig(minimal=True, root_controller=RootController())
tg.hooks.wrap_controller(app_controller_wrapper)
tg.hooks.wrap_controller(controller_wrapper, controller=RootController.test)
conf.package = PackageWithModel()
app = conf.make_wsgi_app()
app = TestApp(app)
assert 'HI!' in app.get('/test')
assert wrapper_has_been_visited[0] is True
assert app_wrapper_has_been_visited[0] is True
示例3: __init__
def __init__(self, folder, values=None):
if values is None:
values = {}
AppConfig.__init__(self)
# First we setup some base values that we know will work
self.renderers = ["genshi", "mako", "jinja", "json", "jsonp", "kajiki"]
self.render_functions = tg.util.Bunch()
self.package = tests.test_stack
self.default_renderer = "genshi"
self.globals = self
self.auth_backend = None
self.auto_reload_templates = False
self.use_legacy_renderer = False
self.use_dotted_templatenames = False
self.serve_static = False
self["errorpage.enabled"] = False
root = os.path.dirname(os.path.dirname(tests.__file__))
test_base_path = os.path.join(root, "tests", "test_stack")
test_config_path = os.path.join(test_base_path, folder)
self.paths = tg.util.Bunch(
root=test_base_path,
controllers=os.path.join(test_config_path, "controllers"),
static_files=os.path.join(test_config_path, "public"),
templates=[os.path.join(test_config_path, "templates")],
i18n=os.path.join(test_config_path, "i18n"),
)
# then we override those values with what was passed in
for key, value in values.items():
setattr(self, key, value)
示例4: test_disconnect_hooks_multiple_listener
def test_disconnect_hooks_multiple_listener(self):
hook1_has_been_called = []
def hook1_listener():
hook1_has_been_called.append(True)
hook2_has_been_called = []
def hook2_listener():
hook2_has_been_called.append(True)
class RootController(TGController):
@expose()
def test(self):
tg.hooks.notify('custom_hook', controller=RootController.test)
return 'HI!'
conf = AppConfig(minimal=True, root_controller=RootController())
tg.hooks.register('custom_hook', hook1_listener)
tg.hooks.register('custom_hook', hook2_listener)
conf.package = PackageWithModel()
app = conf.make_wsgi_app()
app = TestApp(app)
app.get('/test')
app.get('/test')
tg.hooks.disconnect('custom_hook', hook2_listener)
app.get('/test')
# Disconnecting an unregistered hook should do nothing.
tg.hooks.disconnect('unregistered', hook1_listener)
assert len(hook1_has_been_called) == 3, hook1_has_been_called
assert len(hook2_has_been_called) == 2, hook2_has_been_called
示例5: setup
def setup(self):
conf = AppConfig(minimal=True)
conf.use_dotted_templatenames = True
conf.renderers.append('mako')
conf.package = FakePackage()
self.conf = conf
self.app = conf.make_wsgi_app()
示例6: test_package_no_app_globals
def test_package_no_app_globals(self):
class RootController(TGController):
pass
conf = AppConfig(minimal=True, root_controller=RootController())
conf.package = sys.modules[__name__]
app = conf.make_wsgi_app()
示例7: test_application_test_vars
def test_application_test_vars(self):
conf = AppConfig(minimal=True, root_controller=None)
conf.package = PackageWithModel()
app = conf.make_wsgi_app(global_conf={'debug':True})
app = TestApp(app)
assert 'DONE' in app.get('/_test_vars')
assert request.path == '/_test_vars'
示例8: setup
def setup(self):
class RootController(TGController):
@expose()
def test(self):
return str(bool(EqualsTwo()))
conf = AppConfig(minimal=True, root_controller=RootController())
app = conf.make_wsgi_app()
self.app = TestApp(app)
示例9: test_setup_jinja_without_package
def test_setup_jinja_without_package(self):
class RootController(TGController):
@expose()
def test(self):
return 'HI!'
conf = AppConfig(minimal=True, root_controller=RootController())
conf.renderers = ['jinja']
app = conf.make_wsgi_app()
示例10: test_application_wrapper_blocked_after_milestone
def test_application_wrapper_blocked_after_milestone(self):
class AppWrapper1:
pass
class AppWrapper2:
pass
conf = AppConfig(minimal=True)
conf.register_wrapper(AppWrapper1)
milestones.environment_loaded.reach()
conf.register_wrapper(AppWrapper2)
示例11: __init__
def __init__(self, root_controller='root'):
AppConfig.__init__(self)
self.root_controller = root_controller
self.package = allura
self.renderers = ['json', 'genshi', 'mako', 'jinja']
self.default_renderer = 'genshi'
self.use_sqlalchemy = False
self.use_toscawidgets = True
self.use_transaction_manager = False
self.handle_status_codes = [403, 404]
self.disable_request_extensions = True
示例12: test_application_empty_controller
def test_application_empty_controller(self):
class RootController(object):
def __call__(self, environ, start_response):
return None
conf = AppConfig(minimal=True, root_controller=RootController())
conf.package = PackageWithModel()
app = conf.make_wsgi_app(global_conf={'debug':True})
app = TestApp(app)
r = app.get('/something', status=500)
assert 'No content returned by controller' in r
示例13: setup
def setup(self):
conf = AppConfig(minimal=True, root_controller=i18nRootController())
conf['paths']['root'] = 'tests'
conf['i18n_enabled'] = True
conf['use_sessions'] = True
conf['beaker.session.key'] = 'tg_test_session'
conf['beaker.session.secret'] = 'this-is-some-secret'
conf.renderers = ['json']
conf.default_renderer = 'json'
conf.package = _FakePackage()
app = conf.make_wsgi_app()
self.app = TestApp(app)
示例14: test_enable_routes
def test_enable_routes(self):
if PY3: raise SkipTest()
conf = AppConfig(minimal=True)
conf.enable_routes = True
app = conf.make_wsgi_app()
a = TGApp()
assert a.enable_routes == True
config.pop('routes.map')
config.pop('enable_routes')
示例15: test_setup_ming_persistance_with_url_alone
def test_setup_ming_persistance_with_url_alone(self):
if PY3: raise SkipTest()
package = PackageWithModel()
conf = AppConfig(minimal=True, root_controller=None)
conf.package = package
conf.model = package.model
conf.use_ming = True
conf['ming.url'] = 'mim://inmemdb'
app = conf.make_wsgi_app()
assert app is not None