From d27410594227302de6ee66c1757a955d953bf635 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Thu, 12 Dec 2002 22:49:27 +0000 Subject: > There is an ugly little problem with the DB wrapper class. > > In pg.py the attributes of DB are defined as being the same as > the attributes of the corresponding pgobject "db", using the following ... > The problem is that the attributes of db (which are read only) > are not static (they are actually function calls to PostgreSQL), > especially "status" and "error", but those attributes are copied > and this is done only once when initializing the DB object. > > So, in effect, only the attribute "db.error" of a DB instance > will be updated, but not the attribute "error". Same with "status". > Don't copy the (read only) attributes of the pgobject to the > DB object, but only the methods, and all of them, like this: > > --------------- change in pg.py ------------------ > # Create convience methods, in a way that is still overridable. > for e in self.db.__methods__: > setattr(self, e, getattr(self.db, e)) > ---------------------------------------------------- > > Furthermore, make an addition to the documentation of the > DB wrapper class (i.e. in pygresql-pg-db.html): > After the sentence "All pgobject methods are included in this class also." > add the following sentence "The pgobject read-only attributes can be > accessed py adding the prefix 'db.' to them." Christoph Zwerschke --- doc/src/sgml/pygresql.sgml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/pygresql.sgml b/doc/src/sgml/pygresql.sgml index 8a002036bbf..3b854d46735 100644 --- a/doc/src/sgml/pygresql.sgml +++ b/doc/src/sgml/pygresql.sgml @@ -1,4 +1,4 @@ - + <application>PyGreSQL</application> - <application>Python</application> Interface @@ -2413,12 +2413,17 @@ loimport(filename) Database Wrapper Class: <classname>DB</classname> - pg module contains a class called - DB. All pgobject - methods are included in this class also. A number of additional - DB class methods are described below. The - preferred way to use this module is as follows (See description of - the initialization method below.): + The pg module contains a class called + DB wrapping a pgobject. + This pgobject can be addressed as a + DB class member named db + to get access to the read-only attributes of the corresponding connection + (e.g. db.error). All pgobject + methods (e.g. query()) are directly included as members + in the class DB also. A number of additional + higher level DB class methods are described below. + The preferred way to use this module is as follows (see description of the + initialization method below): import pg -- cgit v1.2.3