def getWebParaValue(*ks): ret = {} wvs = webapi.input(_unicode=False) for k in ks: if (k in wvs): ret[k] = webapi.input(_unicode=False)[k] return ret
def getWebParaValue(*ks): ret={} wvs=webapi.input(_unicode=False) for k in ks: if(k in wvs): ret[k]=webapi.input(_unicode=False)[k] return ret
def internal(*a, **kw): i = web.input(_method='get') if '_t' in i: try: t = background.threaddb[int(i._t)] except KeyError: return web.notfound() web._context[threading.currentThread()] = web._context[t] return else: return func(*a, **kw)
def validates(self, source=None, _validate=True, **kw): source = source or kw or web.input() out = True for i in self.inputs: v = attrget(source, i.name) if _validate: out = i.validate(v) and out else: i.value = v if _validate: self.valid = out return out
def changequery(**kw): """ 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 = web.input(_method='get') for k, v in kw.iteritems(): if v is None: query.pop(k, None) else: query[k] = v out = web.ctx.homepath + web.ctx.path if query: out += '?' + urllib.urlencode(query) return out
def validates(self, source=None, _validate=True, **kw): source = source or kw or web.input() out = True for i in self.inputs: if hasattr(i,'inputs'): for ii in i.inputs: v = attrget(source, ii.name) if _validate: out = ii.validate(v) and out else: ii.set_value(v) else: v = attrget(source, i.name) if _validate: out = i.validate(v) and out else: i.set_value(v) if _validate: out = out and self._validate(source) self.valid = out return out