我们从Python开源项目中,提取了以下24个代码示例,用于说明如何使用tornado.options.options.group_dict()。
def group_dict(self, group): """The names and values of options in a group. Useful for copying options into Application settings:: from tornado.options import define, parse_command_line, options define('template_path', group='application') define('static_path', group='application') parse_command_line() application = Application( handlers, **options.group_dict('application')) .. versionadded:: 3.1 """ return dict( (opt.name, opt.value()) for name, opt in self._options.items() if not group or group == opt.group_name)
def main(): parse_command_line(final=False) parse_config_file(options.config_file) app = Application( [ ('/', MainHandler), ('/login', LoginHandler), ('/logout', LogoutHandler), ], login_url='/login', **options.group_dict('application')) app.listen(options.port) logging.info('Listening on http://localhost:%d' % options.port) IOLoop.instance().start()
def group_dict(self, group): """The names and values of options in a group. Useful for copying options into Application settings:: from tornado.options import define, parse_command_line, options define('template_path', group='application') define('static_path', group='application') parse_command_line() application = Application( handlers, **options.group_dict('application')) .. versionadded:: 3.1 """ return dict( (name, opt.value()) for name, opt in self._options.items() if not group or group == opt.group_name)
def main(): parse_command_line(final=False) parse_config_file(options.config_file) app = Application( [ ('/', MainHandler), ('/login', LoginHandler), ('/logout', LogoutHandler), ], login_url='/login', **options.group_dict('application')) app.listen(options.port) logging.info('Listening on http://localhost:%d' % options.port) IOLoop.current().start()
def make_app(): """ Create a Tornado app for BackendWebServer. """ return tornado.web.Application([ ("/", MainHandler), (r"/archive", ArchiveHandler), (r"/ranking", RankingHandler), (r"/problem/.+", ProblemHandler), (r"/contestlist", ContestListHandler), (r"/submissions", SubmissionsHandler), (r"/submission", SubmissionDetailsHandler), (r"/register", RegisterHandler), (r"/contest/.+", ContestHandler), (r"/contest/.+/problem/.+", ProblemHandler), (r"/user/.+", UserHandler), (r"/login", LoginHandler), (r"/logout", LogoutHandler), (r"/confirm/.+", UserConfirmationHandler), (r"/recovery/.+", RecoveryHandler) ], **options.group_dict('application'))
def make_app(): """Create tornado app for AdminWebServer.""" return tornado.web.Application(handlers, **options.group_dict('application'))