Skip to content
Snippets Groups Projects
Select Git revision
  • benchmark-tools
  • postgres-lambda
  • master default
  • REL9_4_25
  • REL9_5_20
  • REL9_6_16
  • REL_10_11
  • REL_11_6
  • REL_12_1
  • REL_12_0
  • REL_12_RC1
  • REL_12_BETA4
  • REL9_4_24
  • REL9_5_19
  • REL9_6_15
  • REL_10_10
  • REL_11_5
  • REL_12_BETA3
  • REL9_4_23
  • REL9_5_18
  • REL9_6_14
  • REL_10_9
  • REL_11_4
23 results

pg.py

  • Bruce Momjian's avatar
    d2741059
    > There is an ugly little problem with the DB wrapper class. · d2741059
    Bruce Momjian authored
    >
    > 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
    d2741059
    History
    > There is an ugly little problem with the DB wrapper class.
    Bruce Momjian authored
    >
    > 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