Author: phd
Date: 2006-09-05 09:24:05 -0600 (Tue, 05 Sep 2006)
New Revision: 1905
Modified:
SQLObject/branches/0.7-bugfix/sqlobject/main.py
Log:
Minor optimization - moved the condition out of the loop, used break.
Modified: SQLObject/branches/0.7-bugfix/sqlobject/main.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/main.py 2006-09-05 15:23:48 UTC (rev 1904)
+++ SQLObject/branches/0.7-bugfix/sqlobject/main.py 2006-09-05 15:24:05 UTC (rev 1905)
@@ -1255,10 +1255,11 @@
return getID(obj)
def _findAlternateID(cls, name, dbName, value, connection=None):
- for key, column in cls.sqlmeta.columns.items():
- if (key == name) and isinstance(column, col.SOUnicodeCol):
- if isinstance(value, unicode):
+ if isinstance(value, unicode):
+ for key, column in cls.sqlmeta.columns.items():
+ if (key == name) and isinstance(column, col.SOUnicodeCol):
value = value.encode(column.dbEncoding)
+ break
return (connection or cls._connection)._SO_selectOneAlt(
cls,
[cls.sqlmeta.idName] +
|