durumdara
durumdara at gmail.com
Mon May 7 04:22:01 EDT 2007
Hi! Graham Dumpleton wrote: >> Because the controllers are python modules, it is avoid the "same module >> name" hell (in another modules I can use same name - example index). > > What exactly are you talking about when you say 'same module name hell'? The basic python import problem - example: more index.py. > > module reloading. See the apache.import_module() function described > in: > > http://www.modpython.org/live/current/doc-html/pyapi-apmeth.html Yes, I know it, and now I use it (3.3.1). > >> I know that modpy supports publisher mode, that same like pylons' >> working method. >> >> 1.) >> But I want to know: how the modpython helps me to I do pre- and >> postprocess operations? > > Apache/mod_python actually has a much better developed concept of > request processing phases than Pylons and other monolithic solutions > such as Django. Have a look at the section '4.4.4 Process HTTP > Request' in: > > http://www.fmc-modeling.org/projects/apache/html/4_4Request_Response_Loop.html > It is too complicated for me to understand these process-diagrams of apache. > A post handler or cleanup handler can be registered using the > req.register_cleanup() method. See documentation in: > > http://www.modpython.org/live/current/doc-html/pyapi-mprequest-meth.html > So, read through all those references and try and take it in. Then > perhaps come back with more specific questions with examples of what > you have tried. I simplify my question:. I want to use only two callback functions: the first named "pre" must called by apache *before* the calling of published procedure, and the second (named "post") must called by apache *after* the calling of published procedure. So the question is that: can I set these two callback functions in the PUBLISHER HANDLER to initialize and finalize the request handling? Like in pylons? In pylons the controllers have _before_ and _after_ methods, they are called before/after the calling of the action method. Example: .... XController: def __before__(self): OpenSession() OpenDB() CheckLogin() def __after__(sefl): SaveSession() def index(self): return Response('INDEX!') How to I use same mechanism in modpy3.3.1? Like this pseudocode: <Directory ...> AddHandler publisher prefunctionname Pre postfunctionname Post ... Thanks for your help: dd
|