I've been a TurboGears user for most of my projects but have just been
hired to start a new Pyramid project. Naturally, I'm interested in the
traversal approach to views and routes, but am having trouble figuring
out from the documentation exactly how traversal would work when
spanning across multiple view classes/modules.


Let's look at this typical TurboGears setup, for example (loosely
adapted to Pyramid):

--> The main root factory (myapp/views/root.py): <--
from myapp.views.admin.root import AdminRootView

class RootView(object):
    def __init__(self, request):
        self.request = request

    admin = AdminRootView

    @view_config(renderer='string')
    def index(self):
        return 'index'


--> The admin root (myapp/views/admin/root.py): <--
class AdminRootView(object):
    def __init__(self, request):
        self.request = request


    @view_config(renderer='string')
    def index(self):
        return 'admin index'

    @view_config(name='hello', renderer='string')
    def hello(self):
        return 'admin hello'



Of course, in a TurboGears-style setup, this would expose views for
example.com, example.com/admin/, and example.com/admin/hello. However,
in Pyramid the views for the "sub-views" (/admin/*) don't seem to be
able to be found. I have succeeded in making this approach work by
using a "hybrid" setup (using add_route in the config and a
"route_name" parameter in the view_config), but I can't help but think
that there's got to be an easier way to do this and I'm just missing
something.


So, is this not really the intended use for traversal? The examples I
found in the docs about classed-based traversal only go 1-layer deep
(a Root class). I couldn't seem to land on anything solid explaining a
larger app setup with views in their own subdirectory and hierarchical
parent/child classes as separately traversed views. Am I making things
too verbose, or am I just missing a piece of the puzzle?

Thanks for your help,
Seth

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To post to this group, send email to pylons-de...@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