[mod_python] Profiling mod_python with callables?

Graham Dumpleton graham.dumpleton at gmail.com
Sun Sep 23 22:32:21 EDT 2007


Presuming you are actually using mod_python.publisher as the URL
dispatcher, then  instead of using:

  PythonHandler mod_python.publisher

use:

  PythonHandler mymodule

In your 'mymodule.py' then add:

  from mod_python import publisher

  def handler(req):
    return publisher.handler(req)

Once you have that working, then you can wrap the call to
publisher.handler() with what ever you want, including profiling
tools.

Yes, this will also profile publisher's URL dispatch, but it is the
easiest place to insert it without having to do a bit of magic.

Graham

On 24/09/2007, Webb Sprague <webb.sprague at gmail.com> wrote:
> Could anyone help me think about the following problem?
>
> I have a handler, call it handler.py, in which I assign callable
> objects to variables, creating pages through the magic of URL mapping.
>  For example:
>
> class Foo(object):
>     def __init__(self, title):
>         self.title = title
>
>     def __call__(self, whatever):
>         print "<title>" + title + "</title>"
>
> page1 = Foo('Title 1')
> page2 = Foo('Title 2')
>
> You can thus browse http://blah.com/handler/page1 and
> http://blah.com/handler/page2
>
> I would like to profile everything from this handler page down,
> preferably with a single command like hotshot.profile_everything(...)
> near the top of handler.py.
>
> Can anyone describe how?
>
> Thanks, and let me know if I can submit more information.  I haven't
> included the code because there is just so much of it...
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>


More information about the Mod_python mailing list