本文整理汇总了Python中constants.Constants.instance方法的典型用法代码示例。如果您正苦于以下问题:Python Constants.instance方法的具体用法?Python Constants.instance怎么用?Python Constants.instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类constants.Constants
的用法示例。
在下文中一共展示了Constants.instance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from constants import Constants [as 别名]
# 或者: from constants.Constants import instance [as 别名]
def post(self):
user = users.get_current_user()
if not user:
# Send the user to the login page
self.redirect(users.create_login_url(self.request.uri))
return
assert user
newKey = None
if (self.request.get(Constants.ACTION_WORDS_PARAM) and
self.request.get(Constants.REDIRECT_LINK_PARAM)):
if self.request.get(Constants.ACTION_ID_PARAM):
newAction = ndb.Key('Action', int(self.request.get(Constants.ACTION_ID_PARAM)),
parent=getAccountKey(user.user_id())).get()
else:
newAction = Action(parent=getAccountKey(user.user_id()))
newAction.user_id = user.user_id()
newAction.redirect_link = self.request.get(Constants.REDIRECT_LINK_PARAM)
newAction.actionwords = UserInput(
self.request.get(Constants.ACTION_WORDS_PARAM)).getAllActionWords()
newKey = newAction.put()
if self.request.get(Constants.AJAX_REQUEST_PARAM):
return ajaxSuccess(self)
return self.redirect(listPagePath(Constants.NEW_KEY_PARAM, str(newKey.id())))
if self.request.get(Constants.AJAX_REQUEST_PARAM):
return ajaxFailure(self)
template_values = { 'user_nickname': user.nickname(),
'Constants': Constants.instance(),
'actionwords_input': self.request.get(Constants.ACTION_WORDS_PARAM),
'redirect_link_input': self.request.get(Constants.REDIRECT_LINK_PARAM)}
template = JINJA_ENVIRONMENT.get_template('add.html')
self.response.write(template.render(template_values))
示例2: get
# 需要导入模块: from constants import Constants [as 别名]
# 或者: from constants.Constants import instance [as 别名]
def get(self):
user = users.get_current_user()
if not user:
# Send the user to the login page
self.redirect(users.create_login_url(self.request.uri))
return
assert user
match = self.request.get(Constants.MATCH_PARAM, '')
highlightKey = self.request.get(Constants.NEW_KEY_PARAM, '0')
matchingUserActions = fetchMatchingActions(match, user)
template_values = { 'user_nickname': user.nickname(),
'matching_actions': matchingUserActions,
'user_id': user.user_id(),
'match': match,
'Constants': Constants.instance(),
'highlight_key': int(highlightKey)}
template = JINJA_ENVIRONMENT.get_template('list.html')
self.response.write(template.render(template_values))