Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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)")
Ejemplo n.º 3
0
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('/'))
Ejemplo n.º 4
0
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'/'))
Ejemplo n.º 5
0
 def redirect_to(self, req):
     """
     :param allmydata.webish.MyRequest req:
     """
     ophandle = get_arg(req, "ophandle").decode("utf-8")
     assert ophandle
     here = DecodedURL.from_text(str(URLPath.fromRequest(req)))
     target = here.click(u"/").child(u"operations", ophandle)
     output = get_arg(req, "output")
     if output:
         target = target.add(u"output", output.decode("utf-8"))
     return target
Ejemplo n.º 6
0
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)
Ejemplo n.º 7
0
 def URLPath(self):
     return URLPath.fromRequest(self)
Ejemplo n.º 8
0
 def URLPath(self):
     return URLPath.fromRequest(self)