Skip site navigation (1) Skip section navigation (2)

python - ex: Fix bugs, and add/rename exceptions.

From: jwp(at)pgfoundry(dot)org (James William Pye)
To: pgsql-committers(at)postgresql(dot)org
Subject: python - ex: Fix bugs, and add/rename exceptions.
Date: 2005-08-03 23:15:42
Message-ID: 20050803231542.BCACA11263A2@pgfoundry.org (view raw or flat)
Thread:
Lists: pgsql-committers
Log Message:
-----------
Fix bugs, and add/rename exceptions. The previous implementation used a plain
dictionary to do the mapping of codes to exceptions, this implementation uses
the code.Mapping dictionary subtype to handle this. The get and set methods
provided by code.Mapping makes this process a bit easier.
Change the Message __init__ method to no longer validate that the code is
appropriate for the exception. This check made it difficult to allow
arbitrary codes to be used with Error and is probably more of a pain than a
blessing.

With this change the idea of the 'codes' attribute is gone. It was a pain, so
just go 1-to-1 for codes-to-exceptions. This really helps on useability as it is
not very Pythonic to have to check the 'code' of the exception after catching
it, and handling as needed after the check.

Notable new exceptions:
- The utility AbortTransaction
- Warning exceptions
- Information and Debug messages

Modified Files:
--------------
    ex/src:
        prime.py (r1.7 -> r1.8)
        (http://cvs.pgfoundry.org/cgi-bin/cvsweb.cgi/python/ex/src/prime.py.diff?r1=1.7&r2=1.8)

pgsql-committers by date

Next:From: James William PyeDate: 2005-08-03 23:20:40
Subject: python - ex: Add code and prime unittests.
Previous:From: James William PyeDate: 2005-08-03 22:52:36
Subject: python - ex: Add Mapping class, and fix codes.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group