you'll find that your expectation is more or less correct, as running
the code without the view declarations showed.

The problem here is that even though the route matches, the match by
default uses the default root factory for the context, which is an
IDirectory. Since a regular view is already defined for IDirectory,
that's why you get that as the result. That is, there are two views
registered for that interface and the regular view is more specific,
because it explicitly says it's for IDirectory. The route, on the
other hand, is a general view for any interface.

To solve this, you could explicitly declare the route for IDirectory,
which will always be the context in this case, like this:


That way, the route will match and this will be the view specifically
used for the IDirectory context that will be generated.

Alternatively, you could decide to use a different context object, so
that the view declared for IDirectory does not take precedence. You
can do that using the factory parameter for the route:


Then, the context object can be defined to your liking in models.py:

class TileContext(object):

    def __init__(self, environ):
        self.environ = environ

Any one of these two strategies should work.

Carlos de la Guardia

On Fri, Aug 28, 2009 at 10:28 PM, Russ Ferriday<ru...@topia.com> wrote:
> Hi all,
> First, thanks for the dialog. Helpful answers prompted by helpful questions.
> And thanks to Chris, Agendaless, and contributors, for Repoze. I think I
> like it!  Looking forward to trying chameleon.
> So.. I'm just experimenting and I find adding routes to the virginia example
> to work differently from my initial expectation.
> I added :
>   <route
>     path="/t/*subpath"
>     name="tile_renderer"
>     view=".views.render_tile"
>     />
> before the default views in configure.zcml.
> and to views.py I added:
> def render_tile(context, request):
>     path_info = request.environ['PATH_INFO']
>     return Response(repr(path_info))
> My immediate goal is to have render_tile generate all content under /t,
> while everything else comes from the content directory. You can see that
> currently render_tile simply renders a Response with the subpath info as the
> page text.
> lynx should yield '/t/x', and it does, IF I
> comment out all the view declarations in configure.zcml
> If I leave in all those views, I get
>     No default view for /home/russ/bfgenv/repoze.virginia/content
> I'm guessing that I may need to change the model to make this work.
> Any thoughts?
> Thanks!
> --r.
> Russ Ferriday - Topia Systems - Open Source content management with Plone
> and Zope
> ru...@topia.com - mobile: +1 805 234 6915 - skype: ferriday
> _______________________________________________
> Repoze-dev mailing list
> Repoze-dev@lists.repoze.org
> http://lists.repoze.org/listinfo/repoze-dev
Repoze-dev mailing list

Reply via email to