[SQL-CVS] r4239 - SQLObject/trunk/sqlobject
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <sub...@co...> - 2010-10-05 15:46:40
|
Author: phd Date: 2010-10-05 09:46:33 -0600 (Tue, 05 Oct 2010) New Revision: 4239 Modified: SQLObject/trunk/sqlobject/main.py Log: `set_name` and `delete` are always True. Modified: SQLObject/trunk/sqlobject/main.py =================================================================== --- SQLObject/trunk/sqlobject/main.py 2010-09-30 17:37:57 UTC (rev 4238) +++ SQLObject/trunk/sqlobject/main.py 2010-10-05 15:46:33 UTC (rev 4239) @@ -143,22 +143,18 @@ depends.append(col) return depends -def _collectAttributes(cls, new_attrs, look_for_class, delete=True, - set_name=False): +def _collectAttributes(cls, new_attrs, look_for_class): + """Finds all attributes in `new_attrs` that are instances of + `look_for_class`. The ``.name`` attribute is set for any matching objects. + Returns them as a list. + """ - Finds all attributes in `new_attrs` that are instances of - `look_for_class`. Returns them as a list. If `delete` is true - they are also removed from the `cls`. If `set_name` is true, then - the ``.name`` attribute is set for any matching objects. - """ result = [] for attr, value in new_attrs.items(): if isinstance(value, look_for_class): + value.name = attr + delattr(cls, attr) result.append(value) - if set_name: - value.name = attr - if delete: - delattr(cls, attr) return result class CreateNewSQLObject: @@ -733,12 +729,9 @@ cls._SO_setupSqlmeta(new_attrs, is_base) - implicitColumns = _collectAttributes( - cls, new_attrs, col.Col, set_name=True) - implicitJoins = _collectAttributes( - cls, new_attrs, joins.Join, set_name=True) - implicitIndexes = _collectAttributes( - cls, new_attrs, index.DatabaseIndex, set_name=True) + implicitColumns = _collectAttributes(cls, new_attrs, col.Col) + implicitJoins = _collectAttributes(cls, new_attrs, joins.Join) + implicitIndexes = _collectAttributes(cls, new_attrs, index.DatabaseIndex) if not is_base: cls._SO_cleanDeprecatedAttrs(new_attrs) |