[albatross-users] Help catching an exception...
Sheila King
sheila at thinkspot.net
Mon Oct 11 11:46:31 EST 2004
I want to thank everyone who replied to my inquiry.
It had been quite a long time since I'd delved into the source code of
app.py, and these types of suggestions were just what I needed to get me
back on track.
Thanks again,
--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org
--On Wednesday, September 29, 2004 2:56 PM -0400 Neal Stephenson
<neal at yorku.ca> wrote:
> HI,
>
> Not sure if this is right, but I override handle_exception in a
> subclass of the Application that I use for all my apps.
>
> Neal
>
>
> On Wed, 2004-09-29 at 14:12, Sheila King wrote:
>> Hello,
>>
>> I'm using Albatross to develop an account management interface for the
>> web hosting company that I work for.
>>
>> In the testing process, I have determined that certain type of request
>> urls will cause Albatross to throw an exception, and I'm trying to catch
>> that exception to redirect to a public error page of my choosing so that
>> end users do not see the Python tracebacks.
>>
>> Mind you, it would be some odd circumstance that would even lead to this
>> type of error, but I am hoping to cover as many error situations as I
>> can.
>>
>> The problem is this:
>>
>> A correct URL for the application might look like this:
>>
>> http://example.net/cgi-dev/mgr.py/createlogin
>>
>> But suppose this URL is requested instead:
>> http://example.net/cgi-dev/mgr.py/mgr.py/createlogin
>>
>> Then albatross gives the following traceback:
>> -----
>> Template traceback (most recent call last):
>>
>> Traceback (most recent call last):
>> File "albatross/app.py", line 279, in run
>> self.load_page(ctx)
>> File "albatross/randompage.py", line 29, in load_page
>> self.load_page_module(ctx, page)
>> File "albatross/app.py", line 435, in load_page_module
>> raise ApplicationError('%s (in %s)' % (e, mod_dir))
>> ApplicationError: No module named createlogin (in ./pages/mgr/py)
>> -----
>>
>>
>> In the __main__ function of the mgr.py file I tried adding
>> a try/except to wrap the whole invocation of an albatross app
>> (I know...bad programming...but...well...)
>>
>> Here is the except block I put on:
>>
>> except ApplicationError, e:
>> Request = "http://www.Example.net/cgi-bin/mgr.py/errorpage"
>> app = qaApp()
>> ctx = qaAppContext(app)
>> ctx.locals._errmssg = e
>> app.run(qaRequest(Request))
>>
>> Unfortunately, it appears to be having no effect, and I am still
>> getting the identical traceback as before.
>>
>> I also tried changing the "except" statement to
>>
>> except albatross.ApplicationError, e
>>
>> and also tried adding an import statement at the top of the code
>>
>> from albatross.common import AlbatrossError
>>
>> and changing the except statement to:
>>
>> except AlbatrossError, e
>>
>> But again, no change in the traceback produced for that particular URL.
>>
>>
>> I sure would appreciate any tips on how to catch this error and
>> redirect to an error page of my choosing...
>>
>> Thank you,
>>
>>
>> _______________________________________________
>> Albatross-users mailing list
>> Albatross-users at object-craft.com.au
>> https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users
> --
> Neal Stephenson <neal at yorku.ca> Phone: (416) 736-2100 x40211
> Manager, Development Services Fax: (416) 736-5830
> Communication and Network Services Steacie T103, 4700 Keele St.
> York University Toronto, On., Canada M3J 1P3
>
>
>
More information about the Albatross-users
mailing list