def post(self, *uriargs): """ Request: adminReceiverDesc Response: adminReceiverDesc Errors: InvalidInputFormat, ContextGusNotFound Create a new receiver """ try: request = validateMessage(self.request.body, requests.adminReceiverDesc) receiver_iface = Receiver() new_receiver = yield receiver_iface.new(request) new_receiver_gus = new_receiver['receiver_gus'] # 'contexts' it's a relationship between two tables, and is managed # with a separate method of new() context_iface = Context() yield receiver_iface.receiver_align(new_receiver_gus, request['contexts']) yield context_iface.full_context_align(new_receiver_gus, request['contexts']) new_receiver_desc = yield receiver_iface.get_single(new_receiver_gus) self.set_status(201) # Created self.write(new_receiver_desc) except InvalidInputFormat, e: self.set_status(e.http_status) self.write({'error_message': e.error_message, 'error_code' : e.error_code})
def create_receiver(self, request): store = self.getStore() receiver_iface = Receiver(store) new_receiver = receiver_iface.new(request) new_receiver_gus = new_receiver['receiver_gus'] # 'contexts' it's a relationship between two tables, and is managed # with a separate method of new() context_iface = Context(store) receiver_iface.receiver_align(new_receiver_gus, request['contexts']) context_iface.full_context_align(new_receiver_gus, request['contexts']) new_receiver_desc = receiver_iface.get_single(new_receiver_gus) self.returnData(new_receiver_desc) self.returnCode(201) return self.prepareRetVals()