示例#1
0
文件: form.py 项目: 10sr/jottit
 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
示例#2
0
文件: form.py 项目: anandology/jottit
 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
示例#3
0
 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)
示例#4
0
 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)
示例#5
0
 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)
示例#6
0
    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'