Пример #1
0
    def internal(*a, **kw):
        web.data()  # cache it

        tmpctx = web._context[threading.currentThread()]
        web._context[threading.currentThread()] = utils.storage(web.ctx.copy())

        def newfunc():
            web._context[threading.currentThread()] = tmpctx
            # Create new db cursor if there is one else background thread
            # overwrites foreground cursor causing rubbish data into dbase
            if web.config.get('db_parameters'):
                import db
                db.connect(**web.config.db_parameters)
            func(*a, **kw)
            myctx = web._context[threading.currentThread()]
            for k in myctx.keys():
                if k not in ['status', 'headers', 'output']:
                    try:
                        del myctx[k]
                    except KeyError:
                        pass

        t = threading.Thread(target=newfunc)
        background.threaddb[id(t)] = t
        t.start()
        web.ctx.headers = []
        return seeother(changequery(_t=id(t)))
Пример #2
0
    def internal(*a, **kw):
        web.data() # cache it

        tmpctx = web._context[threading.currentThread()]
        web._context[threading.currentThread()] = utils.storage(web.ctx.copy())

        def newfunc():
            web._context[threading.currentThread()] = tmpctx
            # Create new db cursor if there is one else background thread
            # overwrites foreground cursor causing rubbish data into dbase
            if web.config.get('db_parameters'):
                import db
                db.connect(**web.config.db_parameters)
            func(*a, **kw)
            myctx = web._context[threading.currentThread()]
            for k in myctx.keys():
                if k not in ['status', 'headers', 'output']:
                    try: del myctx[k]
                    except KeyError: pass
        
        t = threading.Thread(target=newfunc)
        background.threaddb[id(t)] = t
        t.start()
        web.ctx.headers = []
        return seeother(changequery(_t=id(t)))
Пример #3
0
    def internal(*a, **kw):
        web.data() # cache it

        tmpctx = web._context[threading.currentThread()]
        web._context[threading.currentThread()] = utils.storage(web.ctx.copy())

        def newfunc():
            web._context[threading.currentThread()] = tmpctx
            func(*a, **kw)
            myctx = web._context[threading.currentThread()]
            for k in myctx.keys():
                if k not in ['status', 'headers', 'output']:
                    try: del myctx[k]
                    except KeyError: pass
        
        t = threading.Thread(target=newfunc)
        background.threaddb[id(t)] = t
        t.start()
        web.ctx.headers = []
        return seeother(changequery(_t=id(t)))
Пример #4
0
    def internal(*a, **kw):
        web.data() # cache it

        tmpctx = web._context[threading.currentThread()]
        web._context[threading.currentThread()] = utils.storage(web.ctx.copy())

        def newfunc():
            web._context[threading.currentThread()] = tmpctx
            func(*a, **kw)
            myctx = web._context[threading.currentThread()]
            for k in myctx.keys():
                if k not in ['status', 'headers', 'output']:
                    try: del myctx[k]
                    except KeyError: pass
        
        t = threading.Thread(target=newfunc)
        background.threaddb[id(t)] = t
        t.start()
        web.ctx.headers = []
        return seeother(changequery(_t=id(t)))
Пример #5
0
 def __init__(self, ctx, query, urlbits, db=None):
     utils.autoassign(self, locals())
     self.model = urlbits[1]
     self.op_mode = int(query.pop('_op', ['0'])[0])
     
     if ctx.method in ('POST', 'PUT'):
         if '_data' in query:
             # web.debug('~', query.get('_data'))
             _data = query.pop('_data')[0]
         else:
             _data = web.data()
         if _data:
             try: self.data = json_decode(_data)
             except: raise RestyError('data is invalid')
             del _data
         else:
             raise RestyError('no data!')
     else:
         self.data = None