Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > cgi-tb after os.chdir

Reply
Thread Tools

cgi-tb after os.chdir

 
 
Jon Schull
Guest
Posts: n/a
 
      07-14-2003
I find that cgitb fails to show error context if I've changed my
default directory, so I tried to subclass cgitb and get it to save the
directory we were in when the program started. Didn't work. I'd
appreciate your eyes.

Problem--this apparently fails to find my sourcefile when #os.chdir is
uncommented from this cgi program
..........................

#! /usr/local/bin/python
import cgitb
cgitb.enable()

import os
#os.chdir('../')
1/0
..........................
What I thought would work:
..........................
from cgitb import Hook
import os
import sys

class myHook(Hook):
def __init__(self, display=1, logdir=None, context=5,
file=None,wkdir='xx'):
self.wkdir=wkdir
Hook.__init__(self, display=1, logdir=None, context=5, file=None)

def handle(self, info=None):
os.cwd(self.wkdir)
Hook.handle(self,info)

handler = myHook().handle
def enable(display=1, logdir=None, context=5):
wkdir=os.getcwd()
sys.excepthook = myHook(display, logdir, context,wkdir=wkdir)

..........................
But in fact, my exception handler doesn't even seem to get installed.
(I get python's usual tracebacks)

I'm probably over my head here, but...

What's wrong with the program where I attempt to subclass myHook?

Is this a reasonable way to get cgitb to survive directory changes?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
if instance variable get initialize after assigning some values or after constructor then when does static variable get initialize Tony Morris Java 3 02-04-2006 08:39 AM
.NET server becomes slow after several hours, go back normal after restarting IIS davidw ASP .Net 3 08-27-2004 06:25 PM
After adding Textboxes to calender control, how to get values after Postback? Andreas Klemt ASP .Net 0 02-01-2004 02:54 AM
Datalist selects Item after first click, but does apply the SelectedItemTemplate after the second click only Dirk Meusel ASP .Net 1 08-19-2003 09:56 AM



Advertisments