Sounds good, It's good. But I try avoid many `add_route` in Configurator
class, so I use only two routes.

`_get_pet` and pet_id in __init__ it very nice, I'll use this snippet code
:)

Thank you

Mário Idival
Python Developer

*Twitter|Github|Skype *: *marioidival*
*Facebook*: *mario.idival*
*User Linux** : **#554446*

2015-03-05 16:33 GMT-03:00 Blaise Laflamme <bla...@laflamme.org>:

> Mario,
>
> you already got a good answer, but I added another way you could do it by
> using route predicates.
>
> https://gist.github.com/marioidival/60a2a06730947cc32b00
>
> On Wednesday, March 4, 2015 at 10:08:59 PM UTC-5, Mário Idival wrote:
>>
>> Blaise, How do you would using  @view_defaults and @view_config nested?
>> Sorry, I forgot to mention it.
>>
>> https://gist.github.com/marioidival/60a2a06730947cc32b00
>>
>>
>> Mário Idival
>> Python Developer
>>
>> *Twitter|Github|Skype *: *marioidival*
>> *Facebook*: *mario.idival*
>> *User Linux** : **#554446*
>>
>> 2015-03-04 17:41 GMT-03:00 Blaise Laflamme <bla...@laflamme.org>:
>>
>>> to me
>>>
>>> /users
>>> /users/{user_id}
>>> /user or /me
>>>
>>> are all different endpoints and need different routes and different
>>> route names related to actions.
>>>
>>> /user/{user_id} looks weird to me, I would expect collections to have
>>> plural names like /users (except some grammatical exceptions).
>>>
>>> I would use something like:
>>>
>>> /users
>>> GET: route_name='users.list'
>>> POST: route_name='users.create'
>>>
>>> /users/{user_id}
>>> GET: route_name='users.read'
>>> POST/PUT: route_name='users.update'
>>> DELETE: route_name='users.delete'
>>>
>>> On Wednesday, March 4, 2015 at 2:47:12 PM UTC-5, Mário Idival wrote:
>>>>
>>>> ...
>>>>
>>>> I had to create another route to catch a specific User
>>>>
>>>>     config.add_route("users", '/user/')
>>>>     config.add_route("user_details", '/user/{user_id}')
>>>>
>>>>
>>>> Mário Idival
>>>> Python Developer
>>>>
>>>> *Twitter|Github|Skype *: *marioidival*
>>>> *Facebook*: *mario.idival*
>>>> *User Linux** : **#554446*
>>>>
>>>> 2015-03-04 16:45 GMT-03:00 Mário Idival <mario...@gmail.com>:
>>>>
>>>>> I am writing a tutorial, "Creating REST API with Pyramid - free
>>>>> dependencies", and arrived at a point where the GET request should get a
>>>>> list of users and a specific user...
>>>>>
>>>>> /users/
>>>>> /users/{user_id}
>>>>>
>>>>> Mário Idival
>>>>> Python Developer
>>>>>
>>>>> *Twitter|Github|Skype *: *marioidival*
>>>>> *Facebook*: *mario.idival*
>>>>> *User Linux** : **#554446*
>>>>>
>>>>> 2015-03-04 14:52 GMT-03:00 Chris McDonough <chr...@plope.com>:
>>>>>
>>>>> On 03/04/2015 11:03 AM, Jonathan Vanasco wrote:
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Wednesday, March 4, 2015 at 10:30:44 AM UTC-5, Oliver Berger
>>>>>>> wrote:
>>>>>>>
>>>>>>>     If you want the same view executed for several urls just
>>>>>>> decorate it
>>>>>>>     twice with a different route...
>>>>>>>
>>>>>>>
>>>>>>> +1
>>>>>>>
>>>>>>> That's what most people would do.
>>>>>>>
>>>>>>> it would look something like this:
>>>>>>>
>>>>>>>      config.add_route ('test_index', '/ test /')
>>>>>>>      config.add_route ('test_focus', '/ test / {test_id}')
>>>>>>>
>>>>>>>       class MyViews(object):
>>>>>>>          @view_config("test_index")
>>>>>>>          @view_config("test_focus")
>>>>>>>          def test_unified(self):
>>>>>>>               pass
>>>>>>>
>>>>>>
>>>>>>
>>>>>> To be pedantic...
>>>>>>
>>>>>>        class MyViews(object):
>>>>>>           @view_config(route_name="test_index")
>>>>>>           @view_config(route_name="test_focus")
>>>>>>           def test_unified(self):
>>>>>>                pass
>>>>>>
>>>>>> (requires 'route_name=' keyword arg to work properly).
>>>>>>
>>>>>> - C
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "pylons-discuss" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>> send
>>>>>>> an email to pylons-discus...@googlegroups.com
>>>>>>> <mailto:pylons-discuss+unsubscr...@googlegroups.com>.
>>>>>>> To post to this group, send email to pylons-...@googlegroups.com
>>>>>>> <mailto:pylons-...@googlegroups.com>.
>>>>>>> Visit this group at http://groups.google.com/group/pylons-discuss.
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "pylons-discuss" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to pylons-discus...@googlegroups.com.
>>>>>> To post to this group, send email to pylons-...@googlegroups.com.
>>>>>> Visit this group at http://groups.google.com/group/pylons-discuss.
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>
>>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "pylons-discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to pylons-discus...@googlegroups.com.
>>> To post to this group, send email to pylons-...@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/pylons-discuss.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> Visit this group at http://groups.google.com/group/pylons-discuss.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to