def generate_resource(cls, post, resource): from models import BlogDate q = BlogDate.all().order('-__key__') dates = [x.date for x in q] date_struct = {} for date in dates: date_struct.setdefault(date.year, []).append(date) str = utils.render_template("archive.html", { 'generator_class': cls.__name__, 'dates': dates, 'date_struct': date_struct.values(), }) static.set('/archive/', str, config.html_mime_type)
def generate_resource(cls, post, resource): from models import BlogDate q = BlogDate.all().order('-__key__') dates = [x.date for x in q] date_struct = {} for date in dates: date_struct.setdefault(date.year, []).append(date) str = utils.render_template( "archive.html", { 'generator_class': cls.__name__, 'dates': dates, 'date_struct': date_struct.values(), }) static.set('/archive/', str, config.html_mime_type)
def _filter_query(cls, resource, q): from models import BlogDate ts = BlogDate.datetime_from_key_name(resource) # We don't have to bother clearing hour, min, etc., as # datetime_from_key_name() only sets the year and month. min_ts = ts.replace(day=1) # Make the next month the upperbound. # Python doesn't wrap the month for us, so handle it manually. if min_ts.month >= 12: max_ts = min_ts.replace(year=min_ts.year+1, month=1) else: max_ts = min_ts.replace(month=min_ts.month+1) q.filter('published >=', min_ts) q.filter('published <', max_ts)
def _filter_query(cls, resource, q): from models import BlogDate ts = BlogDate.datetime_from_key_name(resource) # We don't have to bother clearing hour, min, etc., as # datetime_from_key_name() only sets the year and month. min_ts = ts.replace(day=1) # Make the next month the upperbound. # Python doesn't wrap the month for us, so handle it manually. if min_ts.month >= 12: max_ts = min_ts.replace(year=min_ts.year + 1, month=1) else: max_ts = min_ts.replace(month=min_ts.month + 1) q.filter('published >=', min_ts) q.filter('published <', max_ts)
def get_resource_list(cls, post): from models import BlogDate return [BlogDate.get_key_name(post)]