示例#1
0
文件: server.py 项目: rtgnx/temboz
def ajax(op, rand, arg):
    item_uid = arg.split('.')[0]
    # for safety, these operations should be idempotent
    if op in ['promote', 'demote', 'basic', 'yappi']:
        if op != 'yappi':
            update.set_rating(int(item_uid), {
                'demote': -1,
                'basic': 0,
                'promote': 1
            }[op])
            return '<?xml version="1.0"?><nothing />'
        else:
            import yappi
            assert arg in ['start', 'stop', 'clear_stats']
            getattr(yappi, arg)()
    return '<?xml version="1.0"?><nothing />'
示例#2
0
 def op_basic(self, item_uid):
   update.set_rating(item_uid, 0)
示例#3
0
 def op_promote(self, item_uid):
   update.set_rating(item_uid, 1)
示例#4
0
 def op_demote(self, item_uid):
   update.set_rating(item_uid, -1)