[mod_python] Profiling mod_python with callables?

Graham Dumpleton graham.dumpleton at gmail.com
Mon Sep 24 00:12:55 EDT 2007


Bouncing this back to list as reply-all not used.

In what way does that not actually work?

Graham

On 24/09/2007, Webb Sprague <webb.sprague at gmail.com> wrote:
> Well, Graham, as usual you are an extremely prompt and helpful
> correspondent... but is there any way to do something like the
> following, which would work per call, giving a regular display and
> writing to a log (if it worked at all)? --
>
>
> ListObjects = LcPageObjects.LcList(lcdb=lcdb,
>                                    navTemplate=LARRYTEMPLATEDIR +
> '/Application.tmpl',
>                                    objectListTemplate =
> LARRYTEMPLATEDIR + '/ObjectList.tmpl',
>                                    title='LAR-E Object List')
> def ListObjectsProfile():
>     global ListObjects
>     return cProfile.run('ListObjects()', '/tmp/ListObjectProf')
>
> Tx
>
> On 9/23/07, Graham Dumpleton <graham.dumpleton at gmail.com> wrote:
> > 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