Update of /cvs-repository/Products/ZGadflyDA In directory cvs.zope.org:/tmp/cvs-serv32028/lib/python/Products/ZGadflyDA
Modified Files: Tag: tseaver-hasattr_geddon-branch DA.py DABase.py Log Message: - Removed all uses of the 'hasattr' builtin from the core, where the object being tested derives (or might) from Persistent. XXX: currently, this branch imports a 'safe_hasattr' from ZODB.utils, which adds a dependency on ZODB for some packages; we probably need a better location, and perhas a C implementation? === Products/ZGadflyDA/DA.py 1.15.68.1 => 1.15.68.1.30.1 === --- Products/ZGadflyDA/DA.py:1.15.68.1 Mon Nov 17 17:34:14 2003 +++ Products/ZGadflyDA/DA.py Sat May 28 20:41:35 2005 @@ -20,6 +20,7 @@ import sys, DABase, Globals import Shared.DC.ZRDB.Connection, ThreadLock from zExceptions import BadRequest +from ZODB.utils import safe_hasattr _Connection=Shared.DC.ZRDB.Connection.Connection @@ -50,13 +51,13 @@ data_sources=data_sources) def connected(self): - if hasattr(self, '_v_database_connection'): + if safe_hasattr(self, '_v_database_connection'): return self._v_database_connection.opened return '' def title_and_id(self): s=_Connection.inheritedAttribute('title_and_id')(self) - if (hasattr(self, '_v_database_connection') and + if (safe_hasattr(self, '_v_database_connection') and self._v_database_connection.opened): s="%s, which is connected" % s else: @@ -65,7 +66,7 @@ def title_or_id(self): s=_Connection.inheritedAttribute('title_and_id')(self) - if (hasattr(self, '_v_database_connection') and + if (safe_hasattr(self, '_v_database_connection') and self._v_database_connection.opened): s="%s (connected)" % s else: === Products/ZGadflyDA/DABase.py 1.12 => 1.12.132.1 === --- Products/ZGadflyDA/DABase.py:1.12 Wed Aug 14 18:25:17 2002 +++ Products/ZGadflyDA/DABase.py Sat May 28 20:41:35 2005 @@ -20,6 +20,7 @@ from Globals import HTMLFile from ExtensionClass import Base import Acquisition +from ZODB.utils import safe_hasattr class Connection(Shared.DC.ZRDB.Connection.Connection): _isAnSQLConnection=1 @@ -63,7 +64,7 @@ def __getitem__(self, name): if name=='tableNamed': - if not hasattr(self, '_v_tables'): self.tpValues() + if not safe_hasattr(self, '_v_tables'): self.tpValues() return self._v_tables.__of__(self) raise KeyError, name _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins