def __before__(self, *args, **kwargs): if not request.settings['appearance_enable_user_uploads']: abort(404) result = BaseController.__before__(self, *args, **kwargs) # BareBonesController will set request.perm if not request.perm.contains_permission('upload'): abort(404) return result
def __call__(self, environ, start_response): """Invoke the Controller""" # BaseController.__call__ dispatches to the Controller method # the request is routed to. This routing information is # available in environ['pylons.routes_dict'] request.identity = request.environ.get('repoze.who.identity') tmpl_context.identity = request.identity return BaseController.__call__(self, environ, start_response)
def __before__(self, *args, **kwargs): """Load all our category data before each request.""" BaseController.__before__(self, *args, **kwargs) c.categories = ( Category.query.order_by(Category.name).options(orm.undefer("media_count_published")).populated_tree() ) counts = dict((cat.id, cat.media_count_published) for cat, depth in c.categories.traverse()) c.category_counts = counts.copy() for cat, depth in c.categories.traverse(): count = counts[cat.id] if count: for ancestor in cat.ancestors(): c.category_counts[ancestor.id] += count category_slug = request.environ["pylons.routes_dict"].get("slug", None) if category_slug: c.category = fetch_row(Category, slug=category_slug) c.breadcrumb = c.category.ancestors() c.breadcrumb.append(c.category)
def __before__(self, *args, **kwargs): """Load all our category data before each request.""" BaseController.__before__(self, *args, **kwargs) c.categories = Category.query\ .order_by(Category.name)\ .options(orm.undefer('media_count_published'))\ .populated_tree() counts = dict((cat.id, cat.media_count_published) for cat, depth in c.categories.traverse()) c.category_counts = counts.copy() for cat, depth in c.categories.traverse(): count = counts[cat.id] if count: for ancestor in cat.ancestors(): c.category_counts[ancestor.id] += count category_slug = request.environ['pylons.routes_dict'].get('slug', None) if category_slug: c.category = fetch_row(Category, slug=category_slug) c.breadcrumb = c.category.ancestors() c.breadcrumb.append(c.category)