On Apr 22, 7:01 pm, "Gregory W. Bond" <[EMAIL PROTECTED]> wrote:
> thanks for the prompt reply wyatt - alas, two levels of nesting isn't
> adequate for my purposes - after looking at the routes documentation,
> i see that routes only supports two levels of nesting which is why, i
> assume, restler has this constraint - it would seem that generalizing
> the routes resource map to handle arbitrary levels of nesting is in
> order....

Yeah, I would like to work on that. For now, though, it is possible to
do something like this, which might work for you:

map.resource('user', 'users')
map.resource('blog', 'blogs', parent_resource={'member_name': 'user',
                                               'collection_name':
'users'})
map.resource('post', 'posts', parent_resource={'member_name': 'blog',
                                               'collection_name':
'blogs'})

This would produce URLs like these, where the grandparent resource is
implicit...

http://mysite.com/users/
http://mysite.com/users/1
http://mysite.com/users/1/blogs
http://mysite.com/users/1/blogs/13
http://mysite.com/blogs/13/articles
http://mysite.com/blogs/13/articles/4

I'm using this style in an app and it works for me so far, but it's
likely there are cases where it won't work for whatever reason.

Route specs for nested resources could be made tidier if, say, it was
possible to pass the return value of map.resource to another
map.resource call. Currently, map.resource doesn't return anything
though. If map.resource returned an object that could be passed back
to map.resource as the parent, then we could do something like this:

user_resource = map.resource('user', 'users')
blog_resource = map.resource('blog', 'blogs',
parent_resource=user_resource)
post_resource = map.resource('post', 'posts',
parent_resource=blog_resource)

post_resource would then produce routes like /users/:user_id/
blogs/:blog_id/posts/:id.

When I find some time, I will look into adding something like this to
Routes.

-Wyatt


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to