Ejemplo n.º 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.
        """
        model_instances = []

        for comic in comics_to_store:
            # urlfetch library is unique to Google App Engine
            logging.info("Fetching %s " % comic)
            image = urlfetch.fetch(comic)
            logging.info("Done fetching %s " % comic)

            # Datastore
            logging.info("Allocating RabiaStore instance for %s" % comic)
            rabia = RabiaStore()
            rabia.encoding = image.headers['content-type']
            rabia.comic = image.content
            rabia.url = comic
            rabia.json = self.json_schema[comic]
            model_instances.append(rabia)
            logging.info("Appending RabiaStore instance to list for %s" % comic)
 
        logging.info("Beginning aggregated datastore write.")
        db.put(model_instances)
        logging.info("Aggreggated datastore write complete.")
Ejemplo n.º 2
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)