tags:

views:

61

answers:

3

Hi I have an application that works fine when I type the url from the browser. it works something like http://mysite/service?id=1234, if I type that on the browser it works fine, however we have another service that accepts parameters from a mobile phone, this service would then call the same url, and post the parameter onto it.

I know it gets as far as urls.py bacause I've put a logging mechanism there, but it doesn't quite make it into the views, i have a logging bit in the view as well.

so that's why I wanted to get the exact request path that the urls.py recieves for me to be able to figure out if the service is screwing something up.

is this possible at all?

+2  A: 

When you say post, do you mean post, or are you using this crucial, extremely specific verb randomly? Because if the request is indeed a post, there will most likely be no ?id=1234 as part of the URL -- the parameters will instead go in the body of the post; the query-string part of the URL is normally used only for GET requests, not POST requests.

Then again, it is quite possible that you're just using extremely specific verbs randomly, since you do say "call the url" which is guaranteed nonsense (one "calls" a function: there is no concept at all of "calling a URL" in the operation of the web;-)... but I'm giving you the benefit of the doubt since, just in case you're using technical terminology correctly, the use of POST would in fact totally explain why the query-string part of the URL, which apparently you expect to be present, might instead most likely be totally absent (with the parameters info transmuted instead into a post-body!).

Alex Martelli
+1. Excellent question-understanding fu.
Manoj Govindan
hi thank you for your response, simply put I just wanted to get access to the HttpRequest.REQUEST from within urls.py so I can get either the url with the querystring, from GET or even just the base url from POST.
Michael
@Michael: if you are trying to troubleshoot why the request is not making it to the view, it would help to post your url config here. Also, you can debug by writing a catch-all view (match "^$" in your url, add it at the top of your config) that merely logs the request in its entirety.
Manoj Govindan
@Michael, thanks for clarifying -- in Django, URL dispatching is normally done through an instance of `django.conf.urls.defaults.patterns` which essentially contains a sequence of pairs, a RE pattern followed by the fully qualified name of the "view" function to use for URLs in that pattern -- that's all, see http://docs.djangoproject.com/en/dev/topics/http/urls/ . I'm not sure, therefore, what `urls.py` are you talking about.
Alex Martelli
@ Manoj Govindan thank you yes im trying to troubleshoot why the request isnt making it to the view. Thank you for your response, I was able to make use of your suggestion, Im able to log requests made via the browser, matching the corrent pattern and everything else. but trying out from our webservice it still stops dead in the urls config never went to any view still, there must be something wrong with how our webservice posts request to urls...
Michael
A: 

Hi here's my urls conf file

from django.conf.urls.defaults import *
from django.http import HttpRequest

logfile = open('/home/jmango/nlagendatest.jmango.net/www/wslog.txt', 'a')
logfile.write("\n\nHEY I GOT TO THE URLS\n")
logfile.close()

urlpatterns = patterns('',
    (r'^$','www.views.logit'),
    (r'ws','www.views.ws'),
Michael
don't answer your own questions just to add more information. answer them if you find an answer that somebody else didn't suggest. edit your question to add more information.
aaronasterling
A: 

Judging from your urls.py: If the view that isn't hit is the ws one, have you tried

 (r'^ws$','www.views.ws'), 

You forgot to include the urls are you testing with, so it's hard to say.

If you're on a unixy system I recommend kodos to test out the regular expression of an urlpattern against an actual url.

kaleissin