You can also whack together a quick Python logger to do the logging, which is what we've done in the past.
Some example code for you: in the __init.py__ for the views (so the logger can be used anywhere) from django.conf import settings import logging # Grabs or creates a new logging object with the string name "edmonds". Since # we are in the model init component, it will probably be creating the logger. ll=logging.getLogger("edmonds") # creates a new handler to write to a file hand = logging.FileHandler(settings.LOGFILE_LOCATION) # sets a formatting object to be used with the handler format = logging.Formatter("%(levelname)-8s %(module)s %(lineno)d %(process)d %(asctime)s %(message)s") # apply the formatting to the handler hand.setFormatter(format) # apply the handler to the logging object ll.addHandler(hand) # Set the minimum logging level. The level we use will probably be one of # logging.INFO, logging.WARNING, or logging.ERROR ll.setLevel(logging.INFO) And then in the view where you want to log: import logging ... ll=logging.getLogger("edmonds") ll.info("Time Point A: ",time.time()) ... do something ... ll.info("Time Point B: ",time.time()) On 3/29/07, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > > > > > On Mar 30, 5:26 am, "Milan Andric" <[EMAIL PROTECTED]> wrote: > > On Mar 28, 6:26 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> > > wrote: > > > > > > > > > On Wed, 2007-03-28 at 19:59 +0000, Milan Andric wrote: > > > > Hellow, > > > > > > Any advice you can offer on optimizing this view would be greatly > > > > appreciated. > > > > > >http://dpaste.com/7543/ > > > > > > I was planning on trying to reduce the amount of data in pForms, the > > > > list that is passed to the template. Since i'm saving 19 > > > > presentations into this list along with the forms, i'm assuming this > > > > is the bottleneck. Any ideas how to work around this? > > > > > Don't assume... test! You can put calls to time.time() in various > places > > > in the view and then print out the differences between them to a file > or > > > to stderr (or even stdout if you are using the development server). > That > > > will show you which portions are taking the longest. With a few > > > iterations, moving the time.time() calls around, you should be able to > > > work out the exact lines that are taking the most time. > > > > > Then come back and we can talk. > > > > > You might discover, for example, that it's not the view that is taking > > > all the time, but the template rendering for some reason (such as > making > > > a lot of database calls by constructing querysets whilst rendering the > > > template). > > > > Hi Malcolm, > > > > Thanks for your response. I'm failing at getting any debug > > information out of the production (apache2/mod_python) environment. I > > tried using print and sys.stderr.write but the logs show no signs of > > it. So there might be something broken there. Will get to that > > later. > > Under mod_python, you must explicitly call flush() on sys.stderr to > have anything appear in Apache logs promptly. Ie., > > print >> sys.stderr, "Hi there!" > sys.stderr.flush() > > If you know you are running under mod_python, you may be better off > using: > > from mod_python import apache > apache.log_error("Hi there!") > > Graham > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---