def GET(self, catslug, pgno=1): cat = get_category_by_slug(catslug) pagination = Pagination(info_record_query2(cat.id), info_count_query2(cat.id), pgno) qs = pagination.queryset entities = qs.all() # import pdb # pdb.set_trace() category_ancestors = get_category_ancestors(cat) req = web.ctx.req req.update( { "entities": entities, "category_ancestors": category_ancestors, "thecat": cat, "pagination": pagination, "get_latest_entities": get_latest_entities, } ) template = cat.template and cat.template.list_file or None if not template or not template_exist(template): template = web.config.default_category_list return info_render.render(template, **req)
def pub_entity_with_template(entity, template): model = entity.model info = getattr(entity, model.name) category_ancestors = get_entitys_category_ancestors(entity) req = web.ctx.req req.update({ 'base_entity': entity, 'entity': info, model.name: info, 'category_ancestors': category_ancestors, }) return info_render.render(template, **req)
def GET(self, slug): cat = get_category_by_slug(slug) req = web.ctx.req req.update({"thecat": cat, "get_latest_entities": get_latest_entities, "get_entity": get_entity}) template = cat.template and cat.template.index_file or None # if template: # web.debug("111 cat:%s 's template:%s" % (cat.slug, template)) if not template or not template_exist(template): template = web.config.default_category_index # if template: # web.debug("222 cat:%s 's template:%s" % (cat.slug, template)) return info_render.render(template, **req)
def GET(self, mname, id): base_entity = get_entity(id) model = base_entity.model entity = getattr(base_entity, model.name) category_ancestors = get_entitys_category_ancestors(base_entity) req = web.ctx.req req.update( { "base_entity": base_entity, "entity": entity, model.name: entity, "category_ancestors": category_ancestors, "get_latest_entities": get_latest_entities, } ) template = model.template.display_file return info_render.render(template, **req)