[mod_python] mod_python weirdness, maybe related to importing?

Mike Looijmans mike.looijmans at asml.com
Tue Jun 10 13:23:43 EST 2003


>Ugh, yeah, it was happening in the SimpleTAL code where I didn't expect
>it to be.  It'd be nice if in debug mode mod_python would throw an
>exception or something if you tried adding headers after there had been
>a write.


You could do this at runtime without having to patch the mod_python code, in
the handler just do:

def handler(req):
    req.write = mywrite
    req.header_out = myheaderout(req)

def mywrite(self, data):
    self.write(data)
    self.headers_sent = 1

class myheaderout():
    ... # init stuff
    def __init__(self, req):
        self.req = req
        self.__get__ = req.header_out.__get__
        # etc. etc.
    def __set__(self, key, value):
        if self.req.headers_sent:
            raise EHeadersSent
        req.header_out[key] = value






-- 
The information contained in this communication and any attachments is confidential and may be privileged, and is for the sole use of the intended recipient(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please notify the sender immediately by replying to this message and destroy all copies of this message and any attachments. ASML is neither liable for the proper and complete transmission of the information contained in this communication, nor for any delay in its receipt.
-- 




More information about the Mod_python mailing list