On Jun 1, 7:03 am, Nick <[EMAIL PROTECTED]> wrote:
> Ive just started using map.resource, but im having a few problems
> determining what is actually being generated. Anyone give me a quick
> pointer on how to look into the data structs generated by routes?
From
http://wiki.pylonshq.com/display/pylonscookbook/How+map.resource+enables+controllers+as+services:
POST /messages -> messages.create() ->
url_for('messages')
GET /messages -> messages.index() ->
url_for('messages')
GET /messages.xml -> messages.index(format='xml') ->
url_for('formatted_messages', format='xml')
GET /messages/new -> messages.new() ->
url_for('new_message')
GET /messages/new.xml -> messages.new(format='xml') ->
url_for('formatted_new_message', format='xml')
PUT /messages/1 -> messages.update(id) ->
url_for('message', id=1)
DELETE /messages/1 -> messages.delete(id) ->
url_for('message', id=1)
GET /messages/1/edit -> messages.edit(id) ->
url_for('edit_message', id=1)
GET /messages/1.xml/edit -> messages.edit(id, format='xml') ->
url_for('formatted_edit_message', id=1, format='xml')
GET /messages/1 -> messages.show(id) ->
url_for('message', id=1)
GET /messages/1.xml -> messages.show(id, format='xml') ->
url_for('formatted_message', id=1, format='xml')
> Basically i've got this:
>
> map.resource('user', 'users', controller='wusers')
>
> And when i do this:
>
> >>> h.url_for('user')
I don't believe that's a valid invocation of the 'user' route.
You could try h.url_for('user', id=4)
to get the url /users/4/show
which should call the show() method on your wusers controller.
I'm not sure what the rest of the problem is, but how did you create
the controller to which you are mapping? If you used restcontroller,
it would have created the python file and class based on the plural
name argument to the restcontroller command. So then using
map.resource as above, there would be no controller to map it to. Or
did you make it from scratch?
Do you really need to have the controller name be different from the
resource name?
>
> it works as it's pointing to the right controller but if i do this
>
> >>> h.url_for('users')
>
> '/users'
>
> it points to the 'users' controller rather than 'wusers'. Anyone have
> any idea either what i'm doing wrong or how i can fix it?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---