
|
If you were logged in you would be able to see more operations.
|
|
|
| Resolution Date: |
08/Oct/06 10:04 AM
|
|
Publisher handler contains the code:
# we log a message if nothing was published, it helps with debugging
if (not published) and (req.bytes_sent==0) and (req.next is None):
log=int(req.get_config().get("PythonDebug", 0))
if log:
req.log_error("mod_python.publisher: nothing to publish.")
The idea is that if the publisher didn't generate any output and simply returned None, that a warning would be generated which might be noticed by a developer and thus be helpful to debugging problems.
Problem is that "req.bytes_sent" is only actually non zero when data is flushed and actually written back to the client by Apache. It does not take into consideration any buffered data.
In other words, if "req.write()" is used but second optional argument is always being set to 0 indicating that data should not be flushed, then publisher will wrongly say nothing actually got published.
Because the PSP classes are no longer flushing data so that output filters like "CONTENT_LENGTH" will work, this will mean you will get this warning all the time when using code like:
from mod_python import apache, psp
def index(req):
page = psp.PSP(req, 'echo.psp')
page.run()
Question is, is there a way to determine from Apache that there is buffered data. We don't really want to be adding another special flag in the mod_python request wrapper like req._content_type_set do we???
|
|
Description
|
Publisher handler contains the code:
# we log a message if nothing was published, it helps with debugging
if (not published) and (req.bytes_sent==0) and (req.next is None):
log=int(req.get_config().get("PythonDebug", 0))
if log:
req.log_error("mod_python.publisher: nothing to publish.")
The idea is that if the publisher didn't generate any output and simply returned None, that a warning would be generated which might be noticed by a developer and thus be helpful to debugging problems.
Problem is that "req.bytes_sent" is only actually non zero when data is flushed and actually written back to the client by Apache. It does not take into consideration any buffered data.
In other words, if "req.write()" is used but second optional argument is always being set to 0 indicating that data should not be flushed, then publisher will wrongly say nothing actually got published.
Because the PSP classes are no longer flushing data so that output filters like "CONTENT_LENGTH" will work, this will mean you will get this warning all the time when using code like:
from mod_python import apache, psp
def index(req):
page = psp.PSP(req, 'echo.psp')
page.run()
Question is, is there a way to determine from Apache that there is buffered data. We don't really want to be adding another special flag in the mod_python request wrapper like req._content_type_set do we???
|
Show » |
|
Couldn't see any other way of doing it if we want a warning for case when nothing output by the handler. Note that one could still have cases where the publisher doesn't produce anything, but did set some output header which was then interpreted by an output filter causing the output filter to produce some actual content for the response.
Being notionally a private member we can always undo this later if we decide to get rid of the warning altogether or we work out a better way of doing it.