本文整理匯總了Python中tornado.options.options.mysql_host方法的典型用法代碼示例。如果您正苦於以下問題:Python options.mysql_host方法的具體用法?Python options.mysql_host怎麽用?Python options.mysql_host使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tornado.options.options
的用法示例。
在下文中一共展示了options.mysql_host方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import mysql_host [as 別名]
def __init__(self):
handlers = [
(r"/", HomeHandler),
(r"/archive", ArchiveHandler),
(r"/feed", FeedHandler),
(r"/entry/([^/]+)", EntryHandler),
(r"/compose", ComposeHandler),
(r"/auth/create", AuthCreateHandler),
(r"/auth/login", AuthLoginHandler),
(r"/auth/logout", AuthLogoutHandler),
]
settings = dict(
blog_title=u"Tornado Blog",
template_path=os.path.join(os.path.dirname(__file__), "templates"),
static_path=os.path.join(os.path.dirname(__file__), "static"),
ui_modules={"Entry": EntryModule},
xsrf_cookies=True,
cookie_secret="__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__",
login_url="/auth/login",
debug=True,
)
super(Application, self).__init__(handlers, **settings)
# Have one global connection to the blog DB across all handlers
self.db = torndb.Connection(
host=options.mysql_host, database=options.mysql_database,
user=options.mysql_user, password=options.mysql_password)
self.maybe_create_tables()
示例2: maybe_create_tables
# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import mysql_host [as 別名]
def maybe_create_tables(self):
try:
self.db.get("SELECT COUNT(*) from entries;")
except MySQLdb.ProgrammingError:
subprocess.check_call(['mysql',
'--host=' + options.mysql_host,
'--database=' + options.mysql_database,
'--user=' + options.mysql_user,
'--password=' + options.mysql_password],
stdin=open('schema.sql'))
示例3: __init__
# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import mysql_host [as 別名]
def __init__(self):
handlers = [
(r"/", HomeHandler),
(r"/archive", ArchiveHandler),
(r"/feed", FeedHandler),
(r"/entry/([^/]+)", EntryHandler),
(r"/compose", ComposeHandler),
(r"/auth/login", AuthLoginHandler),
(r"/auth/logout", AuthLogoutHandler),
]
settings = dict(
blog_title=u"Tornado Blog",
template_path=os.path.join(os.path.dirname(__file__), "templates"),
static_path=os.path.join(os.path.dirname(__file__), "static"),
ui_modules={"Entry": EntryModule},
xsrf_cookies=True,
cookie_secret="11oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=",
login_url="/auth/login",
autoescape=None,
)
tornado.web.Application.__init__(self, handlers, **settings)
# Have one global connection to the blog DB across all handlers
self.db = tornado.database.Connection(
host=options.mysql_host, database=options.mysql_database,
user=options.mysql_user, password=options.mysql_password)