Ejemplo n.º 1
0
    def get(self, mouse_name):
        username = self.get_current_user()
        customer_name = (
            get_user_property(username, UserKeys.CurrentCustomer)
        )
        uri = self.request.uri
        method = self.request.method
        try:
            mouse = mouse_exists(mouse_name)
            mouse = [mouse]
            results = (
                GenericResults(
                    username, uri, method
                ).information_retrieved(mouse, len(mouse))
            )

            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps(results, indent=4))

        except Exception as e:
            results = (
                GenericResults(
                    username, uri, method
                ).something_broke(mouse_name, 'get mouse', e)
            )
            logger.exception(e)
            self.set_status(results['http_status'])
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps(results, indent=4))
Ejemplo n.º 2
0
    def add(self, mouse_name, address, customer_names=[]):

        exists = mouse_exists(mouse_name)
        if exists:
            return (MightyMouseResults(self.username, self.uri,
                                       self.method).exist(mouse_name))
        else:
            status = (add_mouse(customer_names, mouse_name, address,
                                self.username, self.uri, self.method))
            return (status)
Ejemplo n.º 3
0
    def update(self, mouse_name, customer_names=[], address=None):

        exists = mouse_exists(mouse_name)
        if exists:
            status = (update_mouse(exists, mouse_name, customer_names, address,
                                   self.username, self.uri, self.method))
        else:
            status = (add_mouse(customer_names, mouse_name, address,
                                self.username, self.uri, self.method))

        return (status)
Ejemplo n.º 4
0
    def add(self, mouse_name, address, customer_names=[]):

        exists = mouse_exists(mouse_name)
        if exists:
            return(
                MightyMouseResults(
                    self.username, self.uri, self.method
                ).exist(mouse_name)
            )
        else:
            status = (
                add_mouse(
                    customer_names, mouse_name, address,
                    self.username, self.uri, self.method
                )
            )
            return(status)
Ejemplo n.º 5
0
    def update(self, mouse_name, customer_names=[], address=None):

        exists = mouse_exists(mouse_name)
        if exists:
            status = (
                update_mouse(
                    exists, mouse_name, customer_names,
                    address, self.username, self.uri, self.method
                )
            )
        else:
            status = (
                add_mouse(
                    customer_names, mouse_name, address,
                    self.username, self.uri, self.method
                )
            )

        return(status)
Ejemplo n.º 6
0
    def get(self, mouse_name):
        username = self.get_current_user()
        customer_name = (get_user_property(username, UserKeys.CurrentCustomer))
        uri = self.request.uri
        method = self.request.method
        try:
            mouse = mouse_exists(mouse_name)
            mouse = [mouse]
            results = (GenericResults(username, uri,
                                      method).information_retrieved(
                                          mouse, len(mouse)))

            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps(results, indent=4))

        except Exception as e:
            results = (GenericResults(username, uri, method).something_broke(
                mouse_name, 'get mouse', e))
            logger.exception(e)
            self.set_status(results['http_status'])
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps(results, indent=4))