MCPcopy Index your code
hub / github.com/webpy/webpy / changequery

Function changequery

web/http.py:113–129  ·  view source on GitHub ↗

Imagine you're at `/foo?a=1&b=2`. Then `changequery(a=3)` will return `/foo?a=3&b=2` -- the same URL but with the arguments you requested changed.

(query=None, **kw)

Source from the content-addressed store, hash-verified

111
112
113def changequery(query=None, **kw):
114 """
115 Imagine you're at `/foo?a=1&b=2`. Then `changequery(a=3)` will return
116 `/foo?a=3&b=2` -- the same URL but with the arguments you requested
117 changed.
118 """
119 if query is None:
120 query = web.rawinput(method="get")
121 for k, v in iteritems(kw):
122 if v is None:
123 query.pop(k, None)
124 else:
125 query[k] = v
126 out = web.ctx.path
127 if query:
128 out += "?" + urlencode(query, doseq=True)
129 return out
130
131
132def url(path=None, doseq=False, **kw):

Callers

nothing calls this directly

Calls 2

urlencodeFunction · 0.85
popMethod · 0.80

Tested by

no test coverage detected