Dolda2000 GitWeb
/
wrw.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
762f4e4
)
Added some more URI reconstruction tools.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Wed, 28 Nov 2012 04:50:55 +0000
(
05:50
+0100)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Wed, 28 Nov 2012 04:50:55 +0000
(
05:50
+0100)
wrw/proto.py
patch
|
blob
|
blame
|
history
diff --git
a/wrw/proto.py
b/wrw/proto.py
index
b1f0ab3
..
8474b3a
100644
(file)
--- a/
wrw/proto.py
+++ b/
wrw/proto.py
@@
-133,16
+133,26
@@
def appendurl(url, other):
p = local.rfind('/')
return consurl(proto, host, local[:p + 1] + other)
p = local.rfind('/')
return consurl(proto, host, local[:p + 1] + other)
-def
req
url(req):
+def
site
url(req):
host = req.ihead.get("Host", None)
if host is None:
raise Exception("Could not reconstruct URL because no Host header was sent")
proto = "http"
if req.https:
proto = "https"
host = req.ihead.get("Host", None)
if host is None:
raise Exception("Could not reconstruct URL because no Host header was sent")
proto = "http"
if req.https:
proto = "https"
+ return "%s://%s/" % (proto, host)
+
+def scripturl(req):
+ s = siteurl(req)
+ if req.uriname[0] != '/':
+ raise Exception("Malformed local part when reconstructing URL")
+ return siteurl(req) + req.uriname[1:]
+
+def requrl(req):
+ s = siteurl(req)
if req.uri[0] != '/':
raise Exception("Malformed local part when reconstructing URL")
if req.uri[0] != '/':
raise Exception("Malformed local part when reconstructing URL")
- return
"%s://%s%s" % (proto, host, req.uri)
+ return
siteurl(req) + req.uri[1:]
def parstring(pars={}, **augment):
buf = ""
def parstring(pars={}, **augment):
buf = ""