From: Billy G. A. <bal...@us...> - 2001-09-19 03:44:30
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv11395 Modified Files: PgSQL.py Log Message: 19SEP2001 bga On Connection.close(), reset all the attributes to a sane state (i.e. None or 0, as appropiate). --- [Bug #462589] In a fit of optimization, I had introduced a bug that caused comparisons of PgResultSets to anything to fail. This problem has been fixed. Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/PgSQL.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** PgSQL.py 2001/09/18 19:23:35 1.19 --- PgSQL.py 2001/09/19 03:44:26 1.20 *************** *** 33,36 **** --- 33,41 ---- # (rollback) the open transaction when the last cursor is | # closed. | + # --- On Connection.close(), reset all the attributes to a | + # sane state (i.e. None or 0, as appropiate). | + # --- [Bug #462589] In a fit of optimization, I had intro- | + # duced a bug that caused comparisons of PgResultSets to | + # anything to fail. This bug has been squashed. | # 03SEP2001 gh Fixed several cases of references to non-existing | # globals in PgMoney. | *************** *** 69,169 **** # parameter subsitution on the query string if no addi- | # tional parameters are passed to execute. | - # 16JUL2001 bga Fixed a nasty little bug involving the difference be- | - # tween PgInt[2|8] as a type object and PgInt[2|8] as a | - # class. I was not correctly handling the distinction in | - # the code. | - # 12JUN2001 bga Used weak references (if availble) to remove the prob- | - # lem of circular references between the Connection ob- | - # ject and the Cursor objects created with it. The cir- | - # cular references between the Connection object and it's | - # associated TypeCache object are also resolved. | - # 11JUN2001 bga Fixed incorrect reference to .__reset() in the connec- | - # tion object. | - # 10JUN2001 bga Changed .execute() so that if a SELECT statement is | - # executed the remaining results (if any) of a previous | - # SELECT statement is discarded and replaced with the re- | - # sults of the new SELECT query. The previous behaviour | - # was to raise an InterfaceError in that situation. | - # --- Since .execute() will call the reset method as needed, | - # the .reset() method was renamed to .__reset() to make | - # private (at least a private as it gets in Python :-). | - # --- Change 'version' so that it holds the version number of | - # PgSQL.py. PostgreSQL version information is now held | - # in 'version' attribute of the connection object. | - # 09JUN2001 bga Modified the code so that the .close() method in Cursor | - # conforms to the DB-API 2.0 specification. Closing a | - # cursor now prevents it from being used any further, and | - # dis-associates the cursor from it's connection. | - # Commiting or rolling back a transaction will no longer | - # closes all the connection's cursors. It will, however, | - # reset the cursor to it's inital result and invalidate | - # any unread query results. | - # --- Reworked the code so that the .__getattr__() method in | - # Cursor is no longer needed. | - # --- Change ._reset_() so that it closes the PostgreSQL | - # portal, if one is opened. | - # --- Renamed _reset_() to reset() and document it as an ex- | - # tension to the DB-API 2.0 specification. | - # --- Updated the PgSQL.__doc__ string. | - # 04JUN2001 bga Added code to load DateTime from an alternate location | - # (from mx import DateTime) if import DateTime failed. | - # The alternate location came from a patch submitted by | - # Gerhard Häring <gha...@sf...>. | - # 03JUN2001 bga Minor bug fixes and improvments. | - # --- Improved the speed of initializing a new PgResultSet by | - # pre-building the name to index dictionary when the cur- | - # sor description attribute is built. | - # 02JUN2001 bga Modified code to use the C implementation of the PgInt2 | - # object. | - # 01JUN2001 bga Fixed problem with the __pow__ method in the PgInt8 | - # PgInt2, and PgMoney classes. | - # --- Added check to see if PgInt8 was imported from libpq, | - # If so, don't define the PgInt8 class. | - # 27MAY2001 bga Fixed a problem with the emulated numeric types that | - # caused exponetiation ('x ** y') to fail. | - # --- Fixed PgInt8, PgInt2, and PgMoney __rdiv()__ method. | - # --- Added missing __hash__() and __cmp__() methods to | - # PgOther and PgMoney. | - # --- Added missing __hash__() method to PgTypes. | - # --- Changed all occurances of OverflowException to | - # OverflowError. | - # 24MAY2001 bga Cleaned up some minor bugs caused by typos and also | - # cleaned up some minor inefficencies. | - # 22MAY2001 bga Made some additional changes in an effort to imporve | - # performance. Mostly, it was removing __getattr__ from | - # the Connection and Cursor classes. | - # --- Delayed getting the version number of the PostgreSQL | - # backend until the first time a connection to the data- | - # base is made. The newly created connection is used to | - # perform the 'SELECT version()' query. | - # 21MAY2001 bga Made some minor changes to __fetchOneRow() in an effort | - # to improve performance. In particular, setting the | - # variable named PgSQL.fetchReturnsList = 1 will cause | - # __fetchOneRow() (and subsequentially, all the fetch*() | - # methods) to return a list instead of a PgResultSet. | - # This should improve the performance of the fetch*() | - # methods by sacrificing the convenient access methods | - # provided by a PgResultSet. | - # 20MAY2001 bga Made some performance improvments in the following | - # methods/functions: | - # TypeCahce.typecast() | - # Cursor.__getattr__() | - # Cursor.__setattr__() | - # Connection.__setattr__() | - # These changes are based on ideas from Ondrej Palkovsky | - # (on...@us...). | - # 18MAY2001 bga Corrected error in the __nonzero__ method of PgInt2 and | - # PgInt8. | - # --- PostgreSQL only supports read-only cursors. Because of | - # this, any SELECT ... FOR UPDATE queries will not use a | - # PostgreSQL cursor. | - # --- PostgreSQL can now rollback deletions of large objects. | - # Modify PgSQL to reflect that fact. | - # --- Fixed the (broken) handling of empty lists in the | - # _handleArray() function. | - # 07MAY2001 bga PostgreSQL can now rollback drops of tables and indices | # Modify PgSQL to reflect that fact. | # --------- bga Remove prior comments to reduce the size of the flower | ! # box. See revision 1.5 for earlier comments. | #--(H-)-----------------------------------------------------------------+ """ --- 74,80 ---- # parameter subsitution on the query string if no addi- | # tional parameters are passed to execute. | # Modify PgSQL to reflect that fact. | # --------- bga Remove prior comments to reduce the size of the flower | ! # box. See revision 1.19 for earlier comments. | #--(H-)-----------------------------------------------------------------+ """ *************** *** 354,358 **** from libpq import * ! version = '1.5.1' apilevel = '2.0' --- 265,269 ---- from libpq import * ! version = '1.6' apilevel = '2.0' *************** *** 1252,1279 **** return - # __xlatKey transform a string (column name) key into an integer key - # used to access the column data. - def __xlatKey(self, key): - if self._xlatkey.has_key(key): - key = self._xlatkey[key] - else: - lkey = string.lower(key) - if self._xlatkey.has_key(lkey): - key = self._xlatkey[lkey] - else: - raise NameError, key - - return key - def __getattr__(self, key): ! return self.baseObj[self._xlatkey[key]] # We define a __setattr__ routine that will only allow the attributes that # are the column names to be updated. All other attributes are read-only. def __setattr__(self, key, value): ! if key in ('baseObj', ): raise AttributeError, "%s is read-only." % key ! self.__dict__['baseObj'][self.__xlatKey(key)] = value def __len__(self): --- 1163,1181 ---- return def __getattr__(self, key): ! if self._xlatkey.has_key(key): ! return self.baseObj[self._xlatkey[key]] ! raise AttributeError, key # We define a __setattr__ routine that will only allow the attributes that # are the column names to be updated. All other attributes are read-only. def __setattr__(self, key, value): ! if key in ('baseObj', '_xlatkey', '_desc_'): raise AttributeError, "%s is read-only." % key ! if self._xlatkey.has_key(key): ! self.__dict__['baseObj'][self._xlatkey(key)] = value ! else: ! raise AttributeError, key def __len__(self): *************** *** 1635,1642 **** pass - self.__dict__["_isOpen"] = 0 self.__dict__["_cache"] = None ! self.__dict__["notices"] = None self.__dict__["conn"] = None def commit(self): --- 1537,1548 ---- pass self.__dict__["_cache"] = None ! self.__dict__["_isOpen"] = 0 ! self.__dict__["autocommit"] = None self.__dict__["conn"] = None + self.__dict__["cursors"] = None + self.__dict__["inTransaction"] = 0 + self.__dict__["version"] = None + self.__dict__["notices"] = None def commit(self): |