def deny(ticket): task = ticket.task TaskManager.getInstance().terminateTask(task, "auction-deny") if task.is_done(): log.debug("removing task-entry: %s", task.id()) TaskManager.getInstance().removeTask(task) TicketStore.getInstance().release(ticket) del ticket.task
def do_StatusRequest(self, elem, *args, **kw): """Handle status request.""" request = message.MessageBuilder.from_xml(elem.getroottree()) ticket = TicketStore.getInstance().lookup(request.ticket()) status_list = message.StatusList() try: if ticket is not None: task = ticket.task status_list.add(task.id(), task.state(), ticket.id(), task.getStatusInfo()) # remove the task entry if task.is_done() and request.removeEntry(): log.debug("removing task-entry: %s", task.id()) TaskManager.getInstance().removeTask(task) TicketStore.getInstance().release(ticket) del ticket.task elif request.ticket() == "all": log.info("user requested the status of all tasks, remove that functionality") toberemoved = [] for tid, ticket in TicketStore.getInstance().all().iteritems(): if ticket.task: task = ticket.task status_list.add(task.id(), task.state(), ticket.id(), task.getStatusInfo()) # remove the task entry if task.is_done() and request.removeEntry(): toberemoved.append( (ticket, task) ) for (ticket, task) in toberemoved: log.debug("removing task-entry: %s", task.id()) TaskManager.getInstance().removeTask(task) TicketStore.getInstance().release(ticket) del ticket.task else: return message.Error(errcode.TICKET_INVALID, request.ticket()) return status_list except Exception, e: log.warn("status request failed %s", e, exc_info=1)