#2407: [patch] CGI Support for django
-------------------------------------------------------+--------------------
   Reporter:  Martin Glueck <[EMAIL PROTECTED]>  |                Owner:  
adrian                
     Status:  new                                      |            Component:  
Core framework        
    Version:  SVN                                      |           Resolution:  
                      
   Keywords:  cgi                                      |                Stage:  
Design decision needed
  Has_patch:  1                                        |           Needs_docs:  
0                     
Needs_tests:  1                                        |   Needs_better_patch:  
1                     
-------------------------------------------------------+--------------------
Changes (by maney at two14 net):

  * needs_better_patch:  0 => 1

Comment:

 Works for me using 0.95.1, aside from the same issue that's behind the
 old, dismissed bug #285.  Since not having a working admin side would have
 defeated most of the point in using Django, and the blithe suggestion of a
 global rewrite rule was somewhere between distasteful and impossible here,
 I had to find a fix which allows Django to work with this as a CGI, but as
 usual there's a price to be paid (pseudo patch for the 1/22 cgi.py):
 {{{
 
 +    # kluge to give Django the full local part of the URL
 +    # fixes problems like #285 at the cost of injecting a prefix into
 urls.py
 +    environ['PATH_INFO'] = environ['SCRIPT_NAME'] +
 environ.get('PATH_INFO', '')
 
      result = application(environ, start_response)
 }}}
 This fixes the issue with the admin interface going off to points unknown
 after the login screen; it may also handle other places where a non-
 relative URL is generated.  It does break the CGI standard meaning of
 PATH_INFO, so if this were to be adopted I should advise fixing the root
 of the problem in wsgi.py where it stupidly assumes that PATH_INFO is all
 there is to the URL.  I assume this is a relic of the way Django has
 traditionally been deployed (see for example the discouragment of serving
 anything but Django in the mod_python setup docs, etc.)  I would further
 speculate that some similar fix would deal as well with #285 and any
 related issues for FCGI, SCGI, ...?
 
 Oh, the cost.  It is, of course, that the top-level urls.py has to embed
 the added prefix (SCRIPT_NAME) to every url.  In my own experiemntal work
 I renamed urls.py to real_urls.py, and made a "dummy" urls.py that matches
 the prefix and chains to real_urls.py.  It's a bit ugly, and, once again
 assuming that the project cares about working cleanly in a non-mod_python
 environment, should get better support.  I have some handwaving-grade
 ideas about that; perhaps I'll work it up into a patch later.  Since this
 is for a copious spare time project, it's likely I'll just continue as-is
 for at least a while.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/2407#comment:8>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" 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/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to