[SQL-CVS] r2043 - SQLObject/trunk/sqlobject
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <sub...@co...> - 2006-10-27 20:18:18
|
Author: phd Date: 2006-10-27 14:18:25 -0600 (Fri, 27 Oct 2006) New Revision: 2043 Modified: SQLObject/trunk/sqlobject/main.py Log: "hasattr(soClass, name)" is more readable than "name in dir(soClass)" and probably faster. Modified: SQLObject/trunk/sqlobject/main.py =================================================================== --- SQLObject/trunk/sqlobject/main.py 2006-10-27 15:31:17 UTC (rev 2042) +++ SQLObject/trunk/sqlobject/main.py 2006-10-27 20:18:25 UTC (rev 2043) @@ -325,8 +325,8 @@ for base in soClass.__bases__: if hasattr(base, "sqlmeta"): parent_columns.extend(base.sqlmeta.columns.keys()) - if name in dir(soClass): - assert name in parent_columns or name == "childName", ( + if hasattr(soClass, name): + assert (name in parent_columns) or (name == "childName"), ( "The class %s.%s already has a variable or method %r, you cannot " "add the column %r" % (soClass.__module__, soClass.__name__, name, name)) |