Example #1
0
    def store_comics(self, comics_to_store):
        """
        This method accepts a set/list of comic URLs to fetch and store.
        Loops through the list, creates a new instance for each comic
        and stores each instance.
        """
        for comic in comics_to_store:
            # urlfetch library is unique to Google App Engine
            image = urlfetch.fetch(comic)

            # Datastore
            rabia = RabiaStore()
            rabia.encoding = image.headers['content-type']
            rabia.comic = image.content
            rabia.url = comic
            rabia.put()

            if self.interactive == False:
                logging.info("Just stored a record for: %s" % comic)