[mod_python] meets_conditions does not seem to work

Graham Dumpleton grahamd at dscpl.com.au
Wed Nov 22 15:57:21 EST 2006


sliderw hotmail wrote ..
> > > > > Anyway, having said all that, what are you expecting to happen
> and
> > > how
> > > > > do you expect to be able to use req.meets_condition()?
> 
> With update_mtime in 3.3, meets_conditions can be used like this:
> 
>     req.headers_out['ETag'] = '"12345"'
>     req.headers_out['Expires'] = 'Fri, 13 Feb 2009 01:00:00 GMT'
>     mtime = 1000000000
>     req.update_mtime(mtime)
>     req.headers_out['Last-Modified'] = rfc822.formatdate(mtime)
> 
>     status = req.meets_conditions()
>     if status != apache.OK:
>         return status
> 
> But I would prefer this (though not a strong preference):
> 
>     req.headers_out['ETag'] = '"12345"'
>     req.headers_out['Expires'] = 'Fri, 13 Feb 2009 01:00:00 GMT'
>     mtime = 1000000000
>     req.set_last_modified(mtime)
>
>     status = req.meets_conditions()
>     if status != apache.OK:
>         return status
> 
> where set_last_modified takes care of setting both mtime and Last-Modified
> header. This is also how mod_perl does it.
> 
> // from mod_perl source
> static MP_INLINE void
> mpxs_Apache2__RequestRec_set_last_modified(request_rec *r, apr_time_t mtime)
> {
>     if (mtime) {
>         ap_update_mtime(r, mtime);
>     }
>     ap_set_last_modified(r);
> }

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, just
post it here and I will update the documentation. I haven't really fiddled with
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, by
all means send them along as well.

Graham


More information about the Mod_python mailing list