def pull(self): queue_id = int(self.request.POST.get('queue', 1)) item = model.get_available_item_from_queue(queue_id) if not item: raise HTTPNotFound() item.claimed = datetime.datetime.now() model.commit() return ({}, (item.get_json(),))
def command(self): conf = 'config:{0}'.format(self.args[0]) here = os.getcwd() conf = appconfig(conf, relative_to=here) conf.global_conf['running_as_script'] = True load_configuration(config, conf.global_conf, conf.local_conf) init_model(engine_from_config(config, 'sqlalchemy.')) count = 0 for item in model.list_due_items(): item.claimed = None count += 1 model.commit() if count > 0: print >> sys.stderr, 'Released {0} message(s).'.format(count)