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: out = out and self._validate(source) if self.processor: self.processor(self, web.input()) for i in self.inputs: if i.errors: out = False self.valid = out return out
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.ctx[threading.currentThread()] = web.ctx[t] return else: return func(*a, **kw)
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 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 POST(self, operation): params = webapi.input() if hasattr(self, operation) and callable(getattr(self, operation)): # there is a function for operation args = {} for k, v in params.iteritems(): # json-decode parameters, and args[k] = json.loads(v) getattr(self, operation)(**args) # call it with unpacked params else: raise webapi.BadRequest('Invalid method') return 'ok'