url_for("formatted_users", format='json')

see http://routes.groovie.org/manual.html#restful-services.

You may also want to take a look at 
http://wiki.pylonshq.com/display/routes/Routes+2+Spec#url-object,
it's already there in your templates, while in your controllers you
just do
from pylons import url
and then use it much like url_for (the dict access syntax is not
implemented).

On 29 Dic, 03:03, "programmer.py" <[email protected]> wrote:
> Hey thats it.  Is there a way to user url_for to get the proper path?
> Thats how I got the original broken path...
>
> Thanks!
> jw
>
> On Dec 28, 8:26 pm, Wyatt Baldwin <[email protected]> wrote:
>
> > On Dec 28, 4:12 pm, "programmer.py" <[email protected]> wrote:
>
> > > Hi everyone.  I'm sure I'm overlooking something very simple, but I
> > > can't get the `format` parameter to work correctly.
>
> > > Can anyone verify that this is / is not working?
>
> > > Here is how I create the problem (or what I think is the problem):
>
> > > 1.  Create a simple pylons (0.9.7rc4).
>
> > > 2.  Add user restful controller:
> > >     paster restcontroller  user users
>
> > > 3.  Add map.resource to config/routing.py:
> > >     # CUSTOM ROUTES HERE
> > >     map.resource('user', 'users')
>
> > > 4.  Modify user controller
>
> > >     def index(self, format='html'):
> > >         """GET /users: All items in the collection."""
> > >         # url('users')
> > >         return 'Format -> %s' % format
>
> > > 5.  Fetch the resource.
>
> > >http://127.0.0.1:5000/users?format=json
>
> > > After fetching the resource, I expected to see the string 'json', but
> > > instead I see HTML.  Ideas?
>
> > Tryhttp://127.0.0.1:5000/users.json. Passing format as a query param
> > means you'd need to access it via `request.params`.
--~--~---------~--~----~------------~-------~--~----~
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