本文整理汇总了Python中models.Request.request_path方法的典型用法代码示例。如果您正苦于以下问题:Python Request.request_path方法的具体用法?Python Request.request_path怎么用?Python Request.request_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Request
的用法示例。
在下文中一共展示了Request.request_path方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_or_create_request
# 需要导入模块: from models import Request [as 别名]
# 或者: from models.Request import request_path [as 别名]
def get_or_create_request():
'''
Returns a request instance that is global for this request
If this function is called outside of a web request then the user_name is marked as system
'''
thread_ident = thread.get_ident()
request, rq = STATE.get(thread_ident, (None, None))
if not rq:
rq = Request()
if request:
rq.request_path = request.path
if request.user.is_anonymous():
rq.user_name = u'(Anonymous)'
else:
rq.user_pk = request.user.pk
rq.user_name = unicode(request.user)[:255]
else:
rq.user_name = u'(System)'
rq.save()
STATE[thread_ident] = (request, rq)
return rq