[mod_python] meets_conditions does not seem to work

sliderw hotmail sliderw at hotmail.com
Wed Nov 22 19:27:29 EST 2006

>You can do:
>   req.update_mtime(mtime)
>   req.set_last_modified()
>This will achieve the same effect. Unless there is a good reason, where we
>do expose underlying Apache functions, we tend to have them behave in the
>same way, rather than adding additional functionality. That way people can
>to a degree refer to Apache documentation and expect that it will work
>the same way.
>If you feel strongly about it, best thing to do is to log an 'improvement'
>suggestion against issue tracking system so it can be considered in the
>future at some point. Address is:
>   http://issues.apache.org/jira/browse/MODPYTHON
>  > Either way, the documentation of meets_conditions needs to be fixed in
> > 3.3.
>If you want to provide a better example that is more complete and works, 
>post it here and I will update the documentation. I haven't really fiddled 
>this sort of stuff and so would only be assuming any example I put together
>worked. If you have any suggestions for text changes to explain it better, 
>all means send them along as well.

The set_last_modified suggestion is a good one. The meets_conditions 
documentation may be changed to:

Calls the Apache ap_meets_conditions() function which returns a status code. 
If status is apache.OK, generate the content of the response normally. If 
not, simply return status. Note that mtime (and possibly ETag) should be set 
prior to calling this function. The same goes for req.status if the status 
differs from apache.OK.


r.headers_out['Expires'] = 'Mon, 18 Apr 2005 17:30:00 GMT'
r.headers_out['ETag'] = '"1130794f-3774-4584-a4ea-0ab19e684268"'

status = r.meets_conditions()
if status != apache.OK:
  return status

... do expensive generation of the response content ...

All-in-one security and maintenance for your PC.  Get a free 90-day trial! 

More information about the Mod_python mailing list