本文整理汇总了Python中GlobalUtilities.getUsername方法的典型用法代码示例。如果您正苦于以下问题:Python GlobalUtilities.getUsername方法的具体用法?Python GlobalUtilities.getUsername怎么用?Python GlobalUtilities.getUsername使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GlobalUtilities
的用法示例。
在下文中一共展示了GlobalUtilities.getUsername方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: task
# 需要导入模块: import GlobalUtilities [as 别名]
# 或者: from GlobalUtilities import getUsername [as 别名]
def task(self, isAdmin, s):
username = tools.getUsername(self)
logging.info("Loading container for: " + str(username))
session = get_current_session()
redirect = False
mobile_redirect = "none"
user_agent = str(self.request.headers['User-Agent'])
mobile_devices = ["android", "blackberry", "googlebot-mobile", "iemobile", "iphone", "ipod", "opera", "mobile",
"palmos", "webos"]
# If user agent matches anything in the list above, redirect
for m in mobile_devices:
if user_agent.lower().find(m) != -1:
redirect = True
# If user has explicitly requested to be sent to desktop site
try:
if session["no-redirect"] == "1":
redirect = False
mobile_redirect = "block"
except:
pass
if redirect == True:
self.redirect("/m")
try:
template_variables = {"settings": s.key.urlsafe(), "username": username, "mobile_redirect": mobile_redirect}
except:
self.redirect("/login")
if isAdmin == True:
self.response.write(
template.render('pages/container.html', template_variables))
elif isAdmin == False:
self.response.write(
template.render('pages/container_ind.html', template_variables))