summaryrefslogtreecommitdiff
path: root/repoze/bfg/zcml.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2009-10-10 02:30:50 +0000
committerChris McDonough <chrism@agendaless.com>2009-10-10 02:30:50 +0000
commitce8f9b5eadf324b4cc3154004bcf9f1f03e7d6c8 (patch)
tree6dd39091d8e27561541a9ed8ea4f1d0d54b4298f /repoze/bfg/zcml.py
parent048496dbbbbd6679afca52387ddbea2aefd596dd (diff)
downloadpyramid-ce8f9b5eadf324b4cc3154004bcf9f1f03e7d6c8.tar.gz
pyramid-ce8f9b5eadf324b4cc3154004bcf9f1f03e7d6c8.tar.bz2
pyramid-ce8f9b5eadf324b4cc3154004bcf9f1f03e7d6c8.zip
- The ``notfound`` and ``forbidden`` ZCML directives now accept the
following addtional attributes: ``attr``, ``renderer``, and ``wrapper``. These have the same meaning as they do in the context of a ZCML ``view`` directive.
Diffstat (limited to 'repoze/bfg/zcml.py')
-rw-r--r--repoze/bfg/zcml.py51
1 files changed, 35 insertions, 16 deletions
diff --git a/repoze/bfg/zcml.py b/repoze/bfg/zcml.py
index 3faadb24b..adb1f1f31 100644
--- a/repoze/bfg/zcml.py
+++ b/repoze/bfg/zcml.py
@@ -279,29 +279,49 @@ def view(
_view = view # for directives that take a view arg
-class INotFoundViewDirective(Interface):
+class ISystemViewDirective(Interface):
view = GlobalObject(
title=u"",
- description=u"The notfound view callable",
- required=True,
+ description=u"The view function",
+ required=False,
)
-def notfound(_context, view):
- view_utility(_context, view, INotFoundView)
+ attr = TextLine(
+ title=u'The callable attribute of the view object(default is __call__)',
+ description=u'',
+ required=False)
-class IForbiddenViewDirective(Interface):
- view = GlobalObject(
- title=u"",
- description=u"The forbidden view callable",
- required=True,
- )
+ renderer = TextLine(
+ title=u'The renderer asssociated with the view',
+ description=u'',
+ required=False)
-def forbidden(_context, view):
- view_utility(_context, view, IForbiddenView)
+ wrapper = TextLine(
+ title = u'The *name* of the view that acts as a wrapper for this view.',
+ description = u'',
+ required=False)
+
+def notfound(_context, view=None, attr=None, renderer=None, wrapper=None):
+ view_utility(_context, view, attr, renderer, wrapper, INotFoundView)
+
+def forbidden(_context, view=None, attr=None, renderer=None, wrapper=None):
+ view_utility(_context, view, attr, renderer, wrapper, IForbiddenView)
+
+def view_utility(_context, view, attr, renderer, wrapper, iface):
+ if not view:
+ if renderer:
+ def view(context, request):
+ return {}
+ else:
+ raise ConfigurationError('"view" attribute was not specified and '
+ 'no renderer specified')
+
+ if renderer and '.' in renderer:
+ renderer = resource_spec(renderer, package_name(_context.resolve('.')))
-def view_utility(_context, view, iface):
def register():
- derived_view = derive_view(view)
+ derived_view = derive_view(view, attr=attr, renderer_name=renderer,
+ wrapper_viewname=wrapper)
sm = getSiteManager()
sm.registerUtility(derived_view, iface, '', _context.info)
@@ -310,7 +330,6 @@ def view_utility(_context, view, iface):
callable = register,
)
-
class IResourceDirective(Interface):
"""
Directive for specifying that one package may override resources from