xslom03 at vse.cz
Sun Sep 26 11:28:43 EDT 2004
Hi, im new to mod_python, but not new to python, i used to do some jsp and php coding but now im very impressed about mod_python. im able to try this out, but id rather ask you for help first :) my question is: if you are using the mighty publisher handler, it calls a specified function, based on request uri. this is very nice, but sometimes i need the same coding in several handlers, for example, if i handle errors in a standard way, i use the same code over and over again (copy & paste with minor changes) it would be _very_ nice if one could just create a class, use its () operator (the __call__() method) and put some standard behavior in that call. then create an object of this class and publisher handler with request http://somewhere.org/index.py/my_handler would instead of a function 'my_handler' defined in 'index.py' would call my callable object 'my_handler' created in 'index.py' the MyHandler class could look like this: class MyHandler: def __call__(req, ...): self._handle_errors() self._do_some_special_stuff() # ready to override self._log_request() self._generate_html() if i want a special behaviour, no problem -- just subclass 'MyHandler' and change the default behaviour. anyone has tried that? are there any frameworks using it? is it slow? m.