Ejemplo n.º 1
0
    def delete_receiver(self, receiver_gus):

        store = self.getStore()

        receiver_iface = Receiver(store)
        receiver_desc = receiver_iface.get_single(receiver_gus)

        receivertip_iface = ReceiverTip(store)
        # Remove Tip possessed by the receiver
        related_tips = receivertip_iface.get_tips_by_receiver(receiver_gus)
        for tip in related_tips:
            receivertip_iface.personal_delete(tip['tip_gus'])
            # Remind: the comment are kept, and the name do not use a reference
            # but is stored in the comment entry.

        context_iface = Context(store)

        # Just an alignment check that need to be removed
        contexts_associated = context_iface.get_contexts_by_receiver(receiver_gus)
        print "context associated by receiver POV:", len(contexts_associated),\
        "context associated by receiver-DB field:", len(receiver_desc['contexts'])

        context_iface.align_receiver_delete(receiver_desc['contexts'], receiver_gus)

        receiverconf_iface = ReceiverConfs(store)
        receivercfg_list = receiverconf_iface.get_confs_by_receiver(receiver_gus)
        for rcfg in receivercfg_list:
            receiverconf_iface.delete(rcfg['config_id'], receiver_gus)

        # Finally delete the receiver
        receiver_iface.receiver_delete(receiver_gus)

        self.returnData(receiver_desc)
        self.returnCode(200)
        return self.prepareRetVals()
Ejemplo n.º 2
0
    def delete(self, receiver_gus, *uriargs):
        """
        Parameter: receiver_gus
        Request: None
        Response: None
        Errors: InvalidInputFormat, ReceiverGusNotFound
        """

        receiver_iface = Receiver()

        try:
            # TODO parameter receiver_gus validation - InvalidInputFormat
            receiver_desc = yield receiver_iface.get_single(receiver_gus)

            receivertip_iface = ReceiverTip()
            # Remove Tip possessed by the receiver
            related_tips = yield receivertip_iface.get_tips_by_receiver(receiver_gus)
            for tip in related_tips:
                yield receivertip_iface.personal_delete(tip['tip_gus'])
            # Remind: the comment are kept, and the name is not referenced but stored
            # in the comment entry.

            context_iface = Context()

            # TODO make an app log
            contexts_associated = yield context_iface.get_contexts_by_receiver(receiver_gus)
            print "context associated by receiver POV:", len(contexts_associated),\
                "context associated by receiver-DB field:", len(receiver_desc['contexts'])

            yield context_iface.align_receiver_delete(receiver_desc['contexts'], receiver_gus)

            receiverconf_iface = ReceiverConfs()
            # Delete all the receiver configuration associated TODO - App log an number of RCFGs
            receivercfg_list = yield receiverconf_iface.get_confs_by_receiver(receiver_gus)
            for rcfg in receivercfg_list:
                yield receiverconf_iface.delete(rcfg['config_id'], receiver_gus)

            # Finally delete the receiver
            yield receiver_iface.receiver_delete(receiver_gus)
            self.set_status(200)

        except ReceiverGusNotFound, e:

            self.set_status(e.http_status)
            self.write({'error_message': e.error_message, 'error_code' : e.error_code})