Skip to content

Commit

Permalink
- Make compatible with BFG 1.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris McDonough committed Mar 31, 2010
1 parent 6c0f9f1 commit 1d37e25
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 163 deletions.
11 changes: 9 additions & 2 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
Next release
------------

- Make compatible with BFG 1.2.

0.2
---

Changes to support upcoming bfg release (which does not require
- Changes to support upcoming bfg release (which does not require
zope.security, so we don't either).

0.1
---

Initial release.
- Initial release.

2 changes: 1 addition & 1 deletion COPYRIGHT.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Copyright (c) 2008 Agendaless Consulting and Contributors.
Copyright (c) 2008-2010 Agendaless Consulting and Contributors.
(http://www.agendaless.com), All Rights Reserved

26 changes: 11 additions & 15 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ Create a ``bfg:viewgroup`` registration in ZCML via the
name="tabs_group"
viewnames="login_tab content_tab"
for=".interfaces.ISite"
request_type="repoze.bfg.interfaces.IRequest"
/>

The consitutient attributes of this directive are:
The consituent attributes of this directive are:

``name`` -- The name by which the viewgroup can be found via traversal
or programmatic view execution. This attribute has the same meaning
Expand All @@ -71,18 +70,13 @@ The consitutient attributes of this directive are:
This attribute has the same meaning as its counterpart in
``bfg:view`` directive.

``request_type`` -- The "model" interface which this view is
registered for. This attribute has the same meaning as its
counterpart in ``bfg:view`` directive.
The ``for`` argument is optional; it defaults to ``None``. The
``name`` argument is also optional. It defaults to the empty string
(indicating the default view).

The ``for`` and ``request_type`` arguments are optional; they default
to ``zope.interface.Interface`` and ``repoze.bfg.interfaces.IRequest``
respectively. The ``name`` argument is also optional. It defaults to
the empty string (indicating the default view).

Viewgroups registered wih a ``name``, ``for`` and ``request_type``
will conflict with views registered with the same arguments, so it's
wise to name your viewgroups differently than your views.
Viewgroups registered wih a ``name`` and a ``for`` and will conflict
with views registered with the same arguments, so it's wise to name
your viewgroups differently than your views.

A viewgroup can refer to another viewgroup in its ``viewname``
argument as necessary (although this is insane).
Expand All @@ -106,11 +100,13 @@ instance of ``Provider`` can be constructed and passed into a template
rendering so it may be used ala the ``provider:`` expression type in
Zope 3. For example, this view might render a template::

from repoze.bfg.view import bfg_view

@bfg_view(template='templates/mytemplate.pt')
def myview(context, request):
from repoze.bfg.viewgroup.group import Provider
provider = Provider(context, request)
return render_template_to_response('templates/mytemplate.pt',
provider=provider)
return {'provider':provider}

The template being rendered can use the provider to "fill slots" by
passing in view or viewgroup names as necessary, e.g.::
Expand Down
1 change: 0 additions & 1 deletion TODO.txt

This file was deleted.

9 changes: 2 additions & 7 deletions repoze/bfg/viewgroup/group.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import itertools

from zope.interface import implements

from webob import Response

from repoze.bfg.interfaces import IView
from repoze.bfg.security import Unauthorized
from repoze.bfg.exceptions import Forbidden
from repoze.bfg.view import render_view_to_iterable
from repoze.bfg.view import render_view

class ViewGroup(object):
implements(IView)

def __init__(self, name, viewnames):
self.name = name
self.viewnames = viewnames
Expand All @@ -22,7 +17,7 @@ def __call__(self, context, request):
for viewname in self.viewnames:
try:
iterable = render_view_to_iterable(context, request, viewname)
except Unauthorized:
except Forbidden:
continue
if iterable is None:
raise ValueError(
Expand Down
1 change: 0 additions & 1 deletion repoze/bfg/viewgroup/tests/fixtureapp/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
name="group"
viewnames="one two"
for=".models.IFixture"
request_type=".views.IDummy"
/>

</configure>
Loading

0 comments on commit 1d37e25

Please sign in to comment.