本文整理匯總了Python中tornado.locale.setter方法的典型用法代碼示例。如果您正苦於以下問題:Python locale.setter方法的具體用法?Python locale.setter怎麽用?Python locale.setter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tornado.locale
的用法示例。
在下文中一共展示了locale.setter方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: locale
# 需要導入模塊: from tornado import locale [as 別名]
# 或者: from tornado.locale import setter [as 別名]
def locale(self):
"""返回當前session的位置.
通過 `get_user_locale` 來確定, 你可以複寫這個方法設置
獲取locale的條件, e.g., 記錄在數據庫中的用戶偏好, 或
`get_browser_locale`, 使用 ``Accept-Language`` 頭部.
.. versionchanged: 4.1
添加setter屬性.
"""
if not hasattr(self, "_locale"):
self._locale = self.get_user_locale()
if not self._locale:
self._locale = self.get_browser_locale()
assert self._locale
return self._locale
示例2: locale
# 需要導入模塊: from tornado import locale [as 別名]
# 或者: from tornado.locale import setter [as 別名]
def locale(self) -> tornado.locale.Locale:
"""The locale for the current session.
Determined by either `get_user_locale`, which you can override to
set the locale based on, e.g., a user preference stored in a
database, or `get_browser_locale`, which uses the ``Accept-Language``
header.
.. versionchanged: 4.1
Added a property setter.
"""
if not hasattr(self, "_locale"):
loc = self.get_user_locale()
if loc is not None:
self._locale = loc
else:
self._locale = self.get_browser_locale()
assert self._locale
return self._locale
示例3: locale
# 需要導入模塊: from tornado import locale [as 別名]
# 或者: from tornado.locale import setter [as 別名]
def locale(self):
"""The locale for the current session.
Determined by either `get_user_locale`, which you can override to
set the locale based on, e.g., a user preference stored in a
database, or `get_browser_locale`, which uses the ``Accept-Language``
header.
.. versionchanged: 4.1
Added a property setter.
"""
if not hasattr(self, "_locale"):
self._locale = self.get_user_locale()
if not self._locale:
self._locale = self.get_browser_locale()
assert self._locale
return self._locale