Ticket #5677: modpython.diff

File modpython.diff, 1.9 KB (added by Nick Efford, 17 years ago)

Patch to modpython.txt to clarify use of print statements

  • docs/modpython.txt

     
    114114When deploying Django sites on mod_python, you'll need to restart Apache each
    115115time you make changes to your Python code.
    116116
     117.. _mod_python documentation: http://modpython.org/live/current/doc-html/directives.html
     118
    117119Multiple Django installations on the same Apache
    118120================================================
    119121
     
    166168revoke your Django privileges.
    167169
    168170If you're the type of programmer who debugs using scattered ``print``
    169 statements, note that ``print`` statements have no effect in mod_python; they
    170 don't appear in the Apache log, as one might expect. If you have the need to
    171 print debugging information in a mod_python setup, either do this::
     171statements, note that writing to ``stdout`` with a regular ``print`` statement
     172is a bad idea.  Things written in this fashion will not appear in the Apache
     173log and may, with some WSGI hosting solutions, end up corrupting valid
     174output sent back to the client.
    172175
    173     assert False, the_value_i_want_to_see
     176If you have the need to print debugging information in a mod_python setup,
     177then you have three options.  The first is to print to ``stderr`` explicitly,
     178like so::
    174179
    175 Or add the debugging information to the template of your page.
     180    print >> sys.stderr, 'debug text'
     181    sys.stderr.flush()
    176182
    177 .. _mod_python documentation: http://modpython.org/live/current/doc-html/directives.html
     183Note that ``stderr`` is buffered, so calling ``flush`` is necessary if you
     184wish debugging information to be displayed promptly.
    178185
     186A second, more compact approach is to use an assertion::
     187
     188    assert False, 'debug text'
     189
     190The third option is to add debugging information to the template of your page.
     191
    179192Serving media files
    180193===================
    181194
Back to Top