I think this can help thanks, thanks a lot :) Well, the idea is that the client may ask for the same information but in XML or JSON format.
But yeah, I think this is the best way to try it out. Thank you very much On 25 nov, 14:36, andrei <[email protected]> wrote: > Sorry, i might misunderstood your question. > > If you need to know between json or xml, you may add format in your > request path "/some/path/to/resourse(.json)?" > > def GET(self, format): > if web.ctx.env.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest': > if format == ".json": > return json.dumps(resource) > else: > return render_partial.resource(resource) > else: > return render.resource(resource) > > On Nov 25, 11:28 pm, andrei <[email protected]> wrote: > > > > > > > > > I use this expression to check if the request is ajax: > > > if web.ctx.env.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest' > > > Works with jquery ajax. > > > On Nov 25, 6:41 pm, Pepe <[email protected]> wrote: > > > > Thank you very much :) > > > > That will truly help. > > > > Well at least I now know where to find it. Is there a way I test this? > > > Either Python coded or "manually". I should be looking for something > > > like "application/xml" or "application/json". With the code you sent > > > me I know how to extract but still I would like to be testing both > > > client and server side to know how to send this, and eventually know > > > if the server is sending me json or xml. > > > > In any way, thanks in advance :) > > > > On 24 nov, 22:58, Anand Chitipothu <[email protected]> wrote: > > > > > 2010/11/24 Pepe <[email protected]>: > > > > > > Hi there, > > > > > > I am using a server using web.py > > > > > > The ctx.environ has a lot of information from the client requesting > > > > > information. One in particular is that the client may request to get > > > > > the response with either json or xml. > > > > > > I would like to know how can I do both things. How can I, as client, > > > > > request for the xml or json format. I know it should be with > > > > > http_variables, but I am not sure how can I request this. Do they have > > > > > to be sent by POST? > > > > > > And while extracting information, how would it be? Do I have to > > > > > extract a param from web.ctx.environ['HTTP_ACCEPT'] or right away with > > > > > web.ctx.environ['HTTP_REQUEST'] > > > > > > Thanks in advance and I hope anybody can help me with this. > > > > > Yes, you need to parse HTTP_ACCEPT. > > > > > Here is a sample code to parse that header. Feel free to adopt it for > > > > your needs. > > > > >https://github.com/openlibrary/infogami/blob/master/infogami/utils/ap... > > > > > Anand -- You received this message because you are subscribed to the Google Groups "web.py" 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/webpy?hl=en.
