From 2cce431f02a37c119eacfc3dfa94af9fe3305de1 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sun, 18 Oct 2009 02:27:43 +0000 Subject: - More than one ``@bfg_view`` decorator may now be stacked on top of any number of others. Each invocation of the decorator registers a single view. For instance, the following combination of decorators and a function will register two views:: from repoze.bfg.view import bfg_view @bfg_view(name='edit') @bfg_view(name='change') def edit(context, request): pass This makes it possible to associate more than one view configuration for a single callable without requiring ZCML. --- repoze/bfg/zcml.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'repoze/bfg/zcml.py') diff --git a/repoze/bfg/zcml.py b/repoze/bfg/zcml.py index a4c18dda9..681c4da1e 100644 --- a/repoze/bfg/zcml.py +++ b/repoze/bfg/zcml.py @@ -693,8 +693,8 @@ class BFGMultiGrokker(martian.core.MultiInstanceOrClassGrokkerBase): class BFGViewGrokker(martian.InstanceGrokker): martian.component(BFGViewMarker) def grok(self, name, obj, **kw): - if hasattr(obj, '__bfg_view_settings__'): - settings = obj.__bfg_view_settings__ + config = getattr(obj, '__bfg_view_settings__', []) + for settings in config: permission = settings['permission'] for_ = settings['for_'] name = settings['name'] @@ -716,8 +716,7 @@ class BFGViewGrokker(martian.InstanceGrokker): request_param=request_param, containment=containment, attr=attr, renderer=renderer, wrapper=wrapper, xhr=xhr, accept=accept, header=header) - return True - return False + return bool(config) def exclude(name): if name.startswith('.'): -- cgit v1.2.3