On Apr 22, 10:33 am, "Gregory W. Bond" <[EMAIL PROTECTED]> wrote:
> i just discovered <a href="http://code.google.com/p/restler/";>restler</
> a> and it appears to be just what i am looking for - however the
> overview, while enticing, does not make it clear how i would go about
> handling more complex URI's
>
> for example, say i wanted to use a URI of the form:
>
> http://mysite.com/users/[userid]/numbers/[number]
>
> here i assume the userid has already been created for the user - how
> do i arrange the routes/controllers/templates for this? or is this
> outside of what restler was designed to accommodate?

Restler does handle nested routes (but only to one level). Here's how
you'd set things up for your example (there might be a typo or two):


## Routes

# http://mysite.com/users/:id
map.resource('user', 'users')
h.link_to('Users', h.url_for('users'))
h.link_to('Show user', h.url_for('user', id=4))

# http://mysite.com/users/:user_id/numbers/:id
# Parent resource, user, has ID name "user_id"
# Nested resource, number, has ID name "id"
map.resource('number', 'numbers',
                        parent_resource={'member_name': 'user',
'collection_name': 'users'})
h.link_to('Numbers', h.url_for('user_numbers', user_id=100))
h.link_to('Show number', h.url_for('user_number', id=13, user_id=42))


## Controllers
## You can override or add actions to these if you need to

# controllers/users.py
from mysite.lib.base import *
class UsersController(RestController): pass

# controllers/numbers.py
from mysite.lib.base import *
class NumbersController(RestController): pass


## Templates

templates/users/
templates/numbers/


If that doesn't answer your questions, I'm glad to provide more info.
I'll also add something about nested resources to the Quick Start.
Thanks for the feedback.


-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