Brian, I just want to clarify some points from your original email.

Specifying the ``factory`` on the route is telling the traversal system how
to get the root of your resource tree for that specific route. Thus in your
example you might do:

def PageFactory(request):
    pagename = request.matchdict.get('page')
    if pagename:
        # page = <query db for a Page object named 'pagename'>
        return page

Specifying the ``context`` parameter on the view is saying "for this view to
match (be invoked), the context object must be an instance of this class (or
interface)". There is a subtle caveat here when using url dispatch.
Traversal stops when the path being traversed is exhausted *OR* when a
KeyError is raised. If you are attempting in your ``PageFactory`` to load a
``Page`` and that fails, raising a KeyError, then the ``PageFactory``
instance will now be the context. ACLs will then be checked against the
``PageFactory`` object instead of your intended ``Page``. In this case you
would probably prefer a 404 instead of having your view be invoked without a
valid ``Page``. Thus, if your view specifies ``route_name='foo'`` *and*
``context=Page``, then you can be sure that view will only be called if the
context is a ``Page``. On top of that if you specify a permission, then the
view is only invoked if that permission was in the ACL as well.

-- 

Michael

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To post to this group, send email to pylons-devel@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-devel?hl=en.

Reply via email to