[mod_python] Tips and Tricks initiative ... some followup contribution /3

vio vmilitaru at sympatico.ca
Wed Jul 3 16:37:49 EST 2002


Already reaching the bottom of my mod_python tricks basket:


REQUEST Attributes Made Easy

Description:
  How can I see all REQUEST's attributes in one swoop.

Solution:
  (one amongst many, I believe)

  def handler(REQUEST):
      # set headers
      REQUEST.content_type = "text/html"
      REQUEST.send_http_header()

      # list all REQUEST's attributes
      REQUEST.write('<HTML><BODY>\n\n')
      for item in dir(REQUEST):
              exec('x = REQUEST.' + str(item))
              REQUEST.write('REQUEST.' + str(item) + ' = ' + str(x))
              REQUEST.write('\n\n<BR>\n\n')

      REQUEST.write('\n\n</BODY></HTML>\n')
      return apache.OK

I hope some may find these little code snipplets useful. I guess other tips&tricks are similarly welcome.

Cheers, Vio



More information about the Mod_python mailing list