Esempio n. 1
0
class GalleryService(Base, LogMixin):
    """Gallery plugin service functions"""
    def __init__(self, settings, contentItem=None):
        self.settings = settings
        self.client = ParseFileRestClient(settings)

    def uploadFiles(self, photos):
        """Upload all the photos from this gallery to server, and adapt each photo w/ response that includes URL"""
        logging.info("uploading files to parse")
        adapted = []
        for photoSets in photos:
            for key in photoSets.keys():
                self.logger.info("Uploading file: %s" % photoSets[key]["output_file"])
                response = self.client.post(photoSets[key]["output_file"], photoSets[key]["filename"])
                if response.has_key("url"):
                    photoSets[key]["parseName"] = response["name"]
                    photoSets[key]["url"] = response["url"]
            adapted.append(photoSets)

        return adapted

    def cleanupOldPhotos(self, photos):
        """Deletes all the photos from an old revision"""
        for photoset in photos:
            for key in photoset.keys():
                photo = photoset[key]
                if photo.has_key("parseName"):
                    self.logger.info("Deleting old file: %s" % photo["parseName"])
                    try:
                        self.client.delete(photo["parseName"])
                    except ParseError:
                        self.logger.error("Could not delete file: %s" % photo["parseName"])
Esempio n. 2
0
class GalleryService(Base, LogMixin):
    """Gallery plugin service functions"""
    def __init__(self, settings, contentItem=None):
        self.settings = settings
        self.client = ParseFileRestClient(settings)

    def uploadFiles(self, photos):
        """Upload all the photos from this gallery to server, and adapt each photo w/ response that includes URL"""
        logging.info("uploading files to parse")
        adapted = []
        for photoSets in photos:
            for key in photoSets.keys():
                self.logger.info("Uploading file: %s" %
                                 photoSets[key]["output_file"])
                response = self.client.post(photoSets[key]["output_file"],
                                            photoSets[key]["filename"])
                if response.has_key("url"):
                    photoSets[key]["parseName"] = response["name"]
                    photoSets[key]["url"] = response["url"]
            adapted.append(photoSets)

        return adapted

    def cleanupOldPhotos(self, photos):
        """Deletes all the photos from an old revision"""
        for photoset in photos:
            for key in photoset.keys():
                photo = photoset[key]
                if photo.has_key("parseName"):
                    self.logger.info("Deleting old file: %s" %
                                     photo["parseName"])
                    try:
                        self.client.delete(photo["parseName"])
                    except ParseError:
                        self.logger.error("Could not delete file: %s" %
                                          photo["parseName"])
Esempio n. 3
0
 def __init__(self, settings, contentItem=None):
     self.settings = settings
     self.client = ParseFileRestClient(settings)
Esempio n. 4
0
 def __init__(self, settings, contentItem=None):
     self.settings = settings
     self.client = ParseFileRestClient(settings)