Example #1
0
    def put(self, receiver_gus, *uriargs):
        """
        Request: adminReceiverDesc
        Response: adminReceiverDesc
        Errors: InvalidInputFormat, ReceiverGusNotFound, ContextGus

        Update information about a Receiver, return the instance updated.
        """

        try:
            # TODO parameter validation - InvalidInputFormat
            request = validateMessage(self.request.body, requests.adminReceiverDesc)

            receiver_iface = Receiver()

            yield receiver_iface.update(receiver_gus, request)

            # '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(receiver_gus, request['contexts'])
            yield context_iface.full_context_align(receiver_gus, request['contexts'])

            receiver_description = yield receiver_iface.get_single(receiver_gus)

            self.set_status(200)
            self.write(receiver_description)

        except InvalidInputFormat, e:

            self.set_status(e.http_status)
            self.write({'error_message': e.error_message, 'error_code' : e.error_code})
Example #2
0
    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})
Example #3
0
    def update_receiver(self, receiver_gus, request):

        store = self.getStore()

        receiver_iface = Receiver(store)
        receiver_iface.update(receiver_gus, request)

        # 'contexts' it's a relationship between two tables, and is managed
        # with a separate method of update()

        context_iface = Context(store)
        receiver_iface.receiver_align(receiver_gus, request['contexts'])
        context_iface.full_context_align(receiver_gus, request['contexts'])

        receiver_description = receiver_iface.get_single(receiver_gus)

        self.returnData(receiver_description)
        self.returnCode(200)
        return self.prepareRetVals()
Example #4
0
    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()