Graham Dumpleton
grahamd at dscpl.com.au
Wed Aug 30 07:17:11 EDT 2006
Please keep followups on the mailing list. A few comments below. On 30/08/2006, at 8:01 PM, Fredrik Sandin wrote: > Dear Graham, > > thanks! Guided by Google, I tried session=Session.Session(req) > (did not realise that it should be stored in req.session) and > ended up with a timeout when trying to load the page. > > The problem was an older version of mod_python, after upgrading > to 3.2.10 it works fine. > > I started learning mod_python a few days ago to implement an > online GUI. The example psp site on the mod_python homepage > set me off in the right direction, I think, because I like > the idea to separate the logic from the templates. However, > I think that the example site/source could benefit from a few > additions: The problem we have at the moment is that current active developers do not have ready access to make modifications to the web site. From memory, not sure that the publisher/PSP example there represents best practice in respect to doing things anyway. Certainly with mod_python 3.3 there are perhaps better ways of doing the same thing. > 1. Show how to handle sessions (as you did above). It is not > sufficient to have access to the session variable inside the > templates when the logic should be factored out elsewhere. > > 2. Show how to handle forms and form input, including argument > matching and type conversion. The same thing applies here, it > is not sufficient to have access to the form variable inside > the templates when the logic should be factored out. If you are using mod_python 3.2.10 or earlier, you have to explicitly pass the form object created by mod_python.publisher into the PSP run() function. From memory: page = psp.PSP(req, filename='...') page.run({"form": req.form}) This is not optimal as PSP tries to decode form parameters a second time, although the mod_python.publisher ones take precedence here since they are passed in. In mod_python 3.3, PSP will automatically use value of req.form which is inherited from something else such as mod_python.publisher. There are various other issues related to forms and session objects and using mod_python.publisher and mod_python.psp together which are also fixed in mod_python 3.3. We will possibly cut a development snapshot of 3.3 soon for initial testing. If you really wanted to use it in the mean time, you would have to use source code out of subversion repository. Graham
|