[mod_python] meets_conditions does not seem to work

sliderw hotmail sliderw at hotmail.com
Wed Nov 22 15:38:52 EST 2006


> > > > 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);
}

Either way, the documentation of meets_conditions needs to be fixed in 3.3.

Thanks for your help.

_________________________________________________________________
Get FREE company branded e-mail accounts and business Web site from 
Microsoft Office Live 
http://clk.atdmt.com/MRT/go/mcrssaub0050001411mrt/direct/01/



More information about the Mod_python mailing list