Ticket #1604 (closed enhancement: fixed)

Opened 6 months ago

Last modified 6 months ago

[PATCH] Improved import list for SQLAlchemy model template

Reported by: chrisz Assigned to: anonymous
Priority: normal Milestone: 1.0.4
Component: TurboGears Version: 1.0.4b2
Severity: normal Keywords: sqlalchemy model import
Cc:

Description

The model template currently imports from SQLAlchemy like that:

from sqlalchemy import (Table, Column, String, DateTime, Date, Integer,
    DECIMAL, Unicode, ForeignKey, and_, or_)

That list is pretty arbitrary. Why is DECIMAL imported, but not the other type aliases? Why are and_ and or_ imported, but not not_? The following three options would be more reasonable:

  1. use from sqlalchemy import * (this provides a quite reasonable set of names)
  2. import only the names that are really used in the standard model.py
  3. import a more complete list explicitly

I have added a patch providing the third option.

Also, the patch changes the multi-line import to use Python 2.3 syntax.

Attachments

model_for_sa.patch (1.0 kB) - added by chrisz on 11/05/07 14:24:56.
Better SQLAlchemy imports in model template (this is for 1.1)

Change History

11/05/07 14:24:56 changed by chrisz

  • attachment model_for_sa.patch added.

Better SQLAlchemy imports in model template (this is for 1.1)

11/06/07 22:02:50 changed by chrisz

  • status changed from new to closed.
  • resolution set to fixed.

Solved in r3617 with option 2. (as before and similar to the SQLObject template).

11/07/07 07:47:52 changed by chrisz

  • status changed from closed to reopened.
  • resolution deleted.

Sorry, I meant solved with option 1. Reopened this ticket since the issue of "import *" is just discussed on the mailing list.

11/25/07 12:02:03 changed by faide

  • status changed from reopened to closed.
  • resolution set to fixed.

import * in the template is the worst situation we could have. The current SVN revision as of r3757 is quite satisfactory.