On Fri, 22 Aug 2008, Dirkjan Ochtman wrote:

> Faheem Mitha wrote:
>> *********************************************************************
>> self.env = req.META where req is a django request (see__init__ of
>> hgReqWrap below).
>> *********************************************************************
>> 
>> self.env is {'AUTH_TYPE': None, 'HTTP_COOKIE': 
>> 'bixfile=d1e2ea28f5cc1d4f43a9a14e0db4970f', 'SERVER_SOFTWARE': 
>> 'mod_python', 'SCRIPT_NAME':
>> None, 'REQUEST_METHOD': 'GET', 'PATH_INFO': '', 'SERVER_PROTOCOL': 
>> 'HTTP/1.1', 'QUERY_STRING': None, 'CONTENT_LENGTH': 0L,
>> 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'REMOTE_USER': 
>> None, 'HTTP_CONNECTION': 'keep-alive', 'SERVER_NAME':
>> 'msi.home.earth', 'REMOTE_ADDR': '192.168.1.204', 'P ATH_TRANSLATED': None, 
>> 'SERVER_PORT': 443, 'HTTP_USER_AGENT': 'Mozilla/5.0 (X11; U;
>> Linux i686; en-US; rv:1.8. 0.14eol) Gecko/20070505 
>> (Debian-1.8.0.15~pre080614d-0etch1) Epiphany/2.14', 'HTTP_HOST': 'msi',
>> 'HTTP_CACHE_CONTROL': 'max-age=0', 'HTTP_ACCEPT': 
>> 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain
>> ;q=0.8,image/png,*/*;q=0.5', 'GATEWAY_INTERFACE': 'CGI/1.1', 
>> 'HTTP_ACCEPT_LANGUAGE': 'en-us,en;q=0.5', 'REMOTE_IDENT': None, 
>> 'CONTENT_TYPE':
>> None, 'REMOTE_HOST': None, 'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 
>> 'HTTP_KEEP_A LIVE': '300'}
>> 
>> ********************************************************************
>
> This are just some of the common HTTP environment keys, but not the whole 
> WSGI environ. You need the latter to pass to hgweb, because hgweb is a WSGI 
> application (expecting WSGI requests: environ, start_response).

Hi Dirkjan,

Thanks for the helpful comment, and taking the time to respond to me on 
IRC. See excerpts from conversation below.

High level summary: It seems like it should be possible to have django do 
proxying for hgweb, but as yet, I haven't seen clear instructions for 
doing so. The first question I'd like to have a clear answer to is

Does the default Django request for current versions of Django have wsgi 
stuff in it, or not? My version doesn't, and I've seen no indication of 
whether more recent versions do. Jespern's code appears to rely on that.

                                                                  Faheem.

*************************************************************************

10:54 < djc> faheem: did you manage to get the django stuff fixed?
10:55 < faheem> djc: No, I haven't fixed the django thing. I'm replying to 
your message right now, actually.
10:59 < faheem> djc: Do you think it likely that more recent django 
actually has this 'wsgi.input' and stuff built into the response? jespern
seems to think so, but I haven't tried upgrading.
11:00 < djc> well, I think Django should have some facility for "mounting" 
other WSGI apps
11:00 < djc> and it probably has the full WSGI environ somewhere
11:00 < djc> req.META is just not what you want
11:00 < faheem> djc: You think jespern's approach is wrong then?
11:01 < djc> oh, I don't really know about his approach
11:01 < faheem> djc: I can't find much info about wsgi + django.
11:01 < djc> what version are you toying with?
11:01 < faheem> djc: There is a wsgi.py.
11:01 < faheem> djc: Snapshot from late may. Was planning to wait for 1.0, 
but could try the beta I suppose.
11:02 < faheem> djc: But the wsgi.py has pretty much zilch documentation. 
I asked on #django and Magus said that people didn't used wsgi that
much. I thought it was an upcoming standard.
11:03 < djc> interesting thing to say
11:04 < faheem> djc: How so?
11:04 < djc> where's the wsgi.py at?
11:05 < djc> because if you ask me, WSGI is the canonical way to put 
Python apps behind web servers
11:05 < djc> and almost everything plays nice with it
11:05 < djc> that I know of
11:05 < faheem> djc: Sec. I'll check.
11:06 < djc> ah, in core.handlers, right?
11:06 < faheem> djc: django/core/handlers
11:06 < faheem> djc: Right.
11:06 < djc> okay, so you can just use req.environ, then
11:07 < faheem> djc: Can you recommend some wsgi docs?
11:07 < faheem> djc: Can you elaborate?
11:07 < djc> the spec is easy to read
11:07 < djc> so, how are you serving this django site?
11:08 < faheem> http://www.wsgi.org/wsgi/Specifications ?
11:08 < faheem> djc: Apache + mod python.
11:08 < djc> I usually read the PEP version
11:08 < faheem> djc: Pretty standard setup.
11:08 < djc> but it's probably the same thing
11:08 < faheem> djc: http://www.python.org/dev/peps/pep-0333/ ?
11:08 < djc> okay, so it won't work with the default mod_python setup
11:08 < djc> yes, that one
11:09 < djc> but since mod_python is pretty much dead in the water anyway, 
this is a good time to switch to mod_wsgi
11:09 < faheem> djc: Ok. is that easy?
11:09 < djc> yes!
11:09 < djc> and should be faster, too
11:09 < djc> the mod_wsgi gcode site probably has good instructions for 
django
11:09 < faheem> djc: Ok, I'll give that a try. Once I've done that, how do 
I proceed?
11:09 < faheem> djc: So, what is wrong with mod python?
11:10 < djc> for one thing, it's hardly being developed anymore
11:10 < djc> for another, it's needlessly complex
11:10 < djc> for a third, the WSGI standard is much nicer to use
11:10 < faheem> djc: So mod wsgi is better overall?
11:10 < djc> yes, emphatically
11:12 < faheem> djc: So with mod wsgi + wsgi.py in django, could I get 
this proxy setup working you think?
11:16 < djc> faheem: I think you want to use middleware to do this
11:17 < faheem> djc: Can you elaborate. To do the proxying, you mean?
11:17 < djc> yes
11:17 < faheem> djc: You mean django middleware, I presume. You mean I'd 
have to write my own?
11:17 < djc> yep
11:18 < djc> apparently, you can have middleware "catch" a request and 
respond to it
11:18 < faheem> djc: I see. Hmm.
11:19 < faheem> djc: How is this different from a view?
11:20 < faheem> djc: A view takes a request and returns a response. Oh, 
well, maybe I'll look at the middleware docs to refresh my memory.
11:20 < djc> the problem is, a request has the environ but not the 
start_response
11:20 < djc> for a WSGI app, you're going to need both
11:21 < djc> hmm, though I'm not sure if you can do that from the 
middleware
11:21 < faheem> djc: I see. No idea what start_reponse is, but looks like 
I have material for further investigation.
11:21 < djc> it's very weird to me that no one has written some code to 
make this possible
11:21  * djc searches djangosnippets
11:21 < faheem> djc: Is start_response a standard term? If so, people on 
#django etc would probably know.
11:22 < djc> yes, it is
11:22 < djc> it's what the WSGI spec defines :)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to