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 />'
def op_basic(self, item_uid): update.set_rating(item_uid, 0)
def op_promote(self, item_uid): update.set_rating(item_uid, 1)
def op_demote(self, item_uid): update.set_rating(item_uid, -1)