本文整理汇总了Python中tg.configuration.AppConfig._setup_controller_wrappers方法的典型用法代码示例。如果您正苦于以下问题:Python AppConfig._setup_controller_wrappers方法的具体用法?Python AppConfig._setup_controller_wrappers怎么用?Python AppConfig._setup_controller_wrappers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tg.configuration.AppConfig
的用法示例。
在下文中一共展示了AppConfig._setup_controller_wrappers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from tg.configuration import AppConfig [as 别名]
# 或者: from tg.configuration.AppConfig import _setup_controller_wrappers [as 别名]
#.........这里部分代码省略.........
self.config.setup_auth()
assert 'sa_auth' in config
self.config.auth_backend = None
def test_register_hooks(self):
def dummy(*args):
pass
milestones.config_ready._reset()
self.config.register_hook('startup', dummy)
self.config.register_hook('shutdown', dummy)
self.config.register_hook('controller_wrapper', dummy)
for hook_name in self.config.hooks.keys():
self.config.register_hook(hook_name, dummy)
milestones.config_ready.reach()
for hooks in self.config.hooks.values():
assert hooks
assert self.config.call_on_startup
assert self.config.call_on_shutdown
assert self.config.controller_wrappers
@raises(TGConfigError)
def test_missing_secret(self):
self.config.auth_backend = 'sqlalchemy'
config.pop('beaker.session.secret', None)
self.config.setup_auth()
def test_controler_wrapper_setup(self):
orig_caller = self.config.controller_caller
self.config.controller_wrappers = []
self.config._setup_controller_wrappers()
assert config['controller_caller'] == orig_caller
def controller_wrapper(app_config, caller):
def call(*args, **kw):
return caller(*args, **kw)
return call
orig_caller = self.config.controller_caller
self.config.controller_wrappers = [controller_wrapper]
self.config._setup_controller_wrappers()
assert config['controller_caller'].__name__ == controller_wrapper(self.config, orig_caller).__name__
def test_global_controller_wrapper(self):
milestones._reset_all()
class RootController(TGController):
@expose()
def test(self):
return 'HI!'
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())
conf.register_hook('controller_wrapper', controller_wrapper)
conf.package = PackageWithModel()
app = conf.make_wsgi_app()
app = TestApp(app)