Esempio n. 1
0
    def get(self, daystring=None):
        """
        As this will generally be run via cron, 'get' is the primary handler,
        even though logically this is more of a 'post' action
        """
        daystring, day = misc_funcs.validate_date(daystring)

        ### Get the relevant feeds from datastore
        feeds = get_feeds_covering_date(day)
        logging.debug("Got %d feeds for %s" % (len(feeds), daystring))

        ### Process the feeds
        package_list = simplify_feeds.simplify_feeds([f.xml for f in feeds])
        logging.debug("%d packages/families for %s" % (len(package_list),
                                                       daystring))
        ### Save feeds to datastore
        pkl = make_pickle_string(package_list)
        daypkg = models.DayPackages(key_name = daystring,
                                    day = day,
                                    day_string = daystring,
                                    pickled_data = pkl)
        daypkg.put()

        # Sanity check
        try:
            unpick = daypkg.unpickle()
        except TypeError, e:
            logging.error("TypeError thrown - pickle can't be unpickled [%s]" %
                          (e))
Esempio n. 2
0
    def get(self, daystring=None):
        daystring, day = misc_funcs.validate_date(daystring)

        # Grab the raw data for the date requested
        logging.debug("daystring is '%s'" % (daystring))
        pkg_model = models.DayPackages.get_by_key_name(daystring)
        if not pkg_model:
            self.error(400) # Bad Request
            return None
        pkg_list = pkg_model.unpickle()

        # Render it to a template

        rendered = content.output_page(self, template_file="update.html",
                                       values={
                "packages": pkg_list,
                "date": daystring}
                                       )
        return HeadersAndContent(content=rendered)