General guidelines

Make it secure
  • Don't expose all your private data members and methods to the world. Prefix everything needed with the underscore '_'
   1   _tags = (1,2,3,4)
   2 
   3   def _foo(a,b):
   4       return a+b
   5 
   6   def handler(req):
   7       return _foo(req['a'], req['b'])

This way, only the handler is accessible from a URL. Both _tags and _foo are hidden.

Session specific guidelines

Let the installation of mod_python decide on the default session manager for you
  • Its usually the best decision This allows your code to be more portable by being independent of the data backing store.
       1    from mod_python import Session
       2    ...
       3    req.session = Session.Session(req)
    
Store your session object back in the ''req'' object.

Best_programming_practices_and_style_guide (last edited 2009-09-20 22:14:37 by localhost)