def decorator(*args, **kwargs): res = func(*args, **kwargs) if type(res) == dict or 200 <= res[1] <= 210: LOG = True # Successful txn, log it. print "yes" _type='DIR' path = request.args.get('path', None) if 'file' in request.args: p = request.args['path'] f = request.args['file'] _type = 'FILE' path = os.path.join(p, f) action = '' if 'move' in request.path: action = 'MOVE' path = request.args['from'] if 'file' in request.path: _type = 'FILE' elif request.method == 'POST': action ='CREATE' elif request.method == 'PUT': action ='UPDATE' elif request.method == 'DELETE': action = 'DELETE' else: LOG = False try: if LOG: tx = Transaction(user=kwargs['username'], type=_type, action=action, pathname=path, ip_address=request.remote_addr ) g.db.add(tx) print "yes" txid = tx.hash() res[0]['txid'] = txid except Exception as e: print e return res