def changequery(**kw):
 query = input(_method='get')
 for (k, v) in kw.iteritems():
  if (v is None):
   query.pop(k, None)
  else:
   query[k] = v
 out = ctx.path
 if query:
  out += ('?' + urllib.urlencode(query))
 return out

def changequery ( ** kw ) : query = input ( _method = 'get' ) for ( k , v ) in kw . iteritems ( ) : if ( v is None ) : query . pop ( k , None ) else : query [ k ] = v out = ctx . path if query : out += ( '?' + urllib . urlencode ( query ) ) return out
imagine youre at /foo?a=1&b=2 .