예제 #1
0
    def parse_update(self):
        result = self.pc.update(self.__class__.__name__, self.object_id, dumps(self.payload))

        # If update fails with code 101, the objectId provided was not found.
        # which means we should create a new object and get a new objectId
        if result.get('code') == 101:
            self.delete()
            self.parse_create()
        else:
            exception_handler(result)
            self.updated_at = result[self.UPDATED_AT_PARSE_FIELD]
예제 #2
0
    def parse_create(self):
        result = self.pc.create(self.__class__.__name__, dumps(self.payload))
        exception_handler(result)

        self.object_id = result[self.OBJECT_ID_PARSE_FIELD]
        self.created_at = result[self.CREATED_AT_PARSE_FIELD]