Few issues with new mod_python.publisher.
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Apache Server configuration support > Apache Mod-Python > Few issues with new mod_python.publisher.




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Few issues with new mod_python.publisher.  
Graham Dumpleton


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-10-05 12:46 PM

Have started to have a look through the latest mod_python.publisher
code, got a few comments to make about it.

First is that it has been changed to allow "HEAD" requests whereas
before it only supported "GET" and "POST". A "HEAD" request is handled
by the mod_python.publisher code saying:

if req.method!='HEAD':
req.write(result)

That is, it is supposed to work by detecting the "HEAD" request and
not actually writing back the result in that case.

This solution though ignores the fact that even with
mod_python.publisher
one can explicitly use the "req" object to write back data. Ie.,

def method(req):
req.content_type = "text/plain"
req.write("data-1\n")
return "data-2\n"

In this case, for a "HEAD" request, one will still get "data-1" sent
back
but "data-2" will not.

I guess the question I have is whether it is worthwhile supporting
"HEAD"
in the first place with mod_python.publisher? What does one actually
gain,
especially when it will not strictly work in all situations?

Second issue is the fact that new mod_python.publisher code uses the
req.finfo attribute. This may be convenient, but it prevents some cute
stuff being done in the future.

It is all about a vision I have of being able to implement middleware
like handler components for mod_python much as WSGI is attempting. In
this case we can use the full power of Apache and mod_python whereas
WSGI is restricted to its minimal server API.

The first thing that really needs to be done to achieve a similar thing
in mod_python is to make req.path_info writable. When this is added to
the fact that req.filename is already writable, it would allow a
middleware
component to setup both req.filename and req.path_info and then trigger
existing mod_python handlers such as mod_python.publisher.handler() to
serve up the request based on these values.

A big benefit of this is that you can put all your web application
Python
code outside of your document tree with just a little middleware stack
within the document tree defining the delegation to the external code.
If someone screws up your Apache configuration and exposes your files,
all that is exposed is the minimal bit of code which performs the
delegation.

Another benefit of modelling stuff as middleware, including wrappers
around existing handlers such as publisher and PSP, is that it becomes
easier to mix use of different mechanisms in a more flexible way without
having to resort to gymnastics in the Apache configuration.

For this sort of thing to work, the middleware component will be what
maps the URL against the external directory and sets up req.filename and
req.path_info as appropriate. Ie., this would no longer be done by
Apache and thus the value of req.finfo is never set to a usable value.
That mod_python.publisher relies on req.finfo means that this sort of
thing may not be practical to do, which would be disappointing. :-(

I realise that people may not understand where I am going with this and
it may be a personal crusade of mine, but have been real busy of late
and haven't had a chance to get my code suitable for general
consumption.

A final issue, is that latest mod_python.publisher no longer pays
attention to result of req.get_addhandler_exts(). This means that where
you used to be able to say:

# .htaccess

AddHandler mod_python .html
PythonHandler mod_python.publisher

# page.py

def index():
return "<html></body><p>XXX</p></body></html>"

with URL of "/page.html", this no longer appears to work for me. In
short it appears that one can only use ".py" as an extension or no
extension at all. Defining another extension to AddHandler or
PythonHandler seems to have no effect.

I'll post about anything else I find another time.

Graham







[ Post a follow-up to this message ]



    Re: Few issues with new mod_python.publisher.  
Juha-Matti Tapio


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-10-05 12:46 PM

On Wed, Aug 10, 2005 at 09:00:31PM +1000, Graham Dumpleton wrote:
> I guess the question I have is whether it is worthwhile supporting 
> "HEAD" in the first place with mod_python.publisher? What does one 
> actually gain, especially when it will not strictly work in all 
> situations?

The RFC specifies that HEAD should return the headers as does GET.

I have summarized the details in:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=297289

HEAD not working causes problems for example when some versions of Firefox
use HEAD to check if the file has changed when saving a document that is
currently open.

I personally would prefer if this worked properly at least on the most
common cases. It is a really difficult error to trace (by adminstrators)
when the browser suddenly claims that the currently open
mod_python-generated document can not be saved because it does not exist.






[ Post a follow-up to this message ]



    Re: Few issues with new mod_python.publisher.  
Graham Dumpleton


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-10-05 12:46 PM

Okay. What though are the implications of content still being returned
for a HEAD request. What does the standard say about that?

On 10/08/2005, at 10:01 PM, Juha-Matti Tapio wrote:

> On Wed, Aug 10, 2005 at 09:00:31PM +1000, Graham Dumpleton wrote: 
>
> The RFC specifies that HEAD should return the headers as does GET.
>
> I have summarized the details in:
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=297289
>
> HEAD not working causes problems for example when some versions of
> Firefox
> use HEAD to check if the file has changed when saving a document that
> is
> currently open.
>
> I personally would prefer if this worked properly at least on the most
> common cases. It is a really difficult error to trace (by
> adminstrators)
> when the browser suddenly claims that the currently open
> mod_python-generated document can not be saved because it does not
> exist.







[ Post a follow-up to this message ]



    Re: Few issues with new mod_python.publisher.  
Juha-Matti Tapio


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-10-05 12:46 PM

On Wed, Aug 10, 2005 at 10:08:08PM +1000, Graham Dumpleton wrote:
> Okay. What though are the implications of content still being returned
> for a HEAD request. What does the standard say about that?

RFC 2616, 9.4 HEAD

The HEAD method is identical to GET except that the server MUST NOT return
a message-body in the response. The metainformation contained in the HTTP
headers in response to a HEAD request SHOULD be identical to the
information sent in response to a GET request.

Ok, now that I read the standard again, it seems that the preferable way to
implement this is to somehow prevent the bytes written from being sent.

Though I have no idea how the user agents would react if they did receive
a message body on HEAD.


-- 
Tmi Juha-Matti Tapio    Puh/Tel. +358-50-5419230
Y-tunnus 1911527-0      Fax      +358-9-34756631






[ Post a follow-up to this message ]



    Re: Few issues with new mod_python.publisher.  
Jorey Bump


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-10-05 10:47 PM

Jim Gallacher wrote:

> Interestingly, section 5.1.1 says that "The methods GET and HEAD MUST be
> supported by all general-purpose servers.", so it would seem that
> mod_python has not been compliant to the RFC.

FWIW, the Debian Woody package of mod_python (libapache-mod-python
2.7.8-0.0woody5) running under apache 1.3.26 displays HEAD properly,
while a compiled mod_python 3.1.4/apache 2.1.3-beta system does not.

Perhaps mod_python underwent a change or Debian already includes a patch
for HEAD.







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 11:18 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register