Changeset 157 for trunk/module/pg.py


Ignore:
Timestamp:
Jun 18, 2004, 10:01:53 AM (15 years ago)
Author:
darcy
Message:

Don't create convenience method for close method as it is wrapped separately
in order to track the state of the database.

In the reopen method, use the class's own close and not the one that it wraps.

The apply method is deprecated so replace them.

Note that reopen doesn't work but it seems to have been broken all along.
Will deal with that separately.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/module/pg.py

    r155 r157  
    4747
    4848        def __init__(self, *args, **kw):
    49                 self.db = apply(connect, args, kw)
     49                self.db = connect(*args, **kw)
    5050
    5151                # Create convenience methods, in a way that is still overridable
    5252                # (members are not copied because they are actually functions)
    5353                for e in self.db.__methods__:
    54                         setattr(self, e, getattr(self.db, e))
     54                        if e != "close":        # close is wrapped separately
     55                                setattr(self, e, getattr(self.db, e))
    5556
    5657                self.__attnames = {}
     
    7778        # note that we can still reopen a database that we have closed
    7879        def reopen(self):
    79                 if self.db: self.db.close()
    80                 try: self.db = apply(connect, self.__args[0], self.__args[1])
     80                if self.db: self.close()
     81                try: self.db = connect(*self.__args[0], **self.__args[1])
    8182                except:
    8283                        self.db = None
Note: See TracChangeset for help on using the changeset viewer.