本文整理汇总了Python中twisted.python.urlpath.URLPath.fromRequest方法的典型用法代码示例。如果您正苦于以下问题:Python URLPath.fromRequest方法的具体用法?Python URLPath.fromRequest怎么用?Python URLPath.fromRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.python.urlpath.URLPath
的用法示例。
在下文中一共展示了URLPath.fromRequest方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: links
# 需要导入模块: from twisted.python.urlpath import URLPath [as 别名]
# 或者: from twisted.python.urlpath.URLPath import fromRequest [as 别名]
def links(self, request, tag):
ds = self.root.edits(self.ob)
therange = range(len(ds))
rev = therange[self.rev]
ul = tags.ul()
for i in therange:
li = tags.li()
if i:
u = URLPath.fromRequest(request)
u = u.sibling('diff')
u.query = urllib.urlencode({
'ob': self.ob.fullName(),
'revA': i-1,
'revB': i,
})
li(tags.a(href=str(u))("(diff)"))
else:
li("(diff)")
li(" - ")
if i == len(ds) - 1:
label = "Latest"
else:
label = str(i)
if i == rev:
li(label)
else:
u = URLPath.fromRequest(request)
u.query = urllib.urlencode({
'rev': str(i),
'ob': self.ob.fullName(),
})
li(tags.a(href=str(u))(label))
li(' - ' + ds[i].user + '/' + ds[i].time)
ul(li)
return tag(ul)
示例2: hist
# 需要导入模块: from twisted.python.urlpath import URLPath [as 别名]
# 或者: from twisted.python.urlpath.URLPath import fromRequest [as 别名]
def hist(self, data, request):
u = URLPath.fromRequest(request)
u = u.sibling('diff')
u.query = urllib.urlencode({
'ob': data.obj.fullName(),
'rev': data.rev,
})
return tags.a(href=str(u))("(hist)")
示例3: base_uri_from_request
# 需要导入模块: from twisted.python.urlpath import URLPath [as 别名]
# 或者: from twisted.python.urlpath.URLPath import fromRequest [as 别名]
def base_uri_from_request(request):
"""
Given a request, return the base URI of the request
:param request: a twisted HTTP request
:type request: :class:`twisted.web.http.Request`
:return: the base uri the request was trying to access
:rtype: ``str``
"""
return str(URLPath.fromRequest(request).click(b'/'))
示例4: absoluteURL
# 需要导入模块: from twisted.python.urlpath import URLPath [as 别名]
# 或者: from twisted.python.urlpath.URLPath import fromRequest [as 别名]
def absoluteURL(request, ob):
if ob.documentation_location == model.DocLocation.PARENT_PAGE:
p = ob.parent
if isinstance(p, model.Module) and p.name == '__init__':
p = p.parent
child = p.fullName() + '.html'
frag = ob.name
elif ob.documentation_location == model.DocLocation.OWN_PAGE:
child = ob.fullName() + '.html'
frag = None
else:
raise AssertionError("XXX")
u = URLPath.fromRequest(request)
u = u.sibling(child)
u.query = ''
u.fragment = frag
return str(u)
示例5: URLPath
# 需要导入模块: from twisted.python.urlpath import URLPath [as 别名]
# 或者: from twisted.python.urlpath.URLPath import fromRequest [as 别名]
def URLPath(self):
return URLPath.fromRequest(self)