Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1604 (closed enhancement: fixed)

Opened 10 years ago

Last modified 10 years ago

[PATCH] Improved import list for SQLAlchemy model template

Reported by: chrisz Owned by: 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 Download (991 bytes) - added by chrisz 10 years ago.
Better SQLAlchemy imports in model template (this is for 1.1)

Change History

Changed 10 years ago by chrisz

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

comment:1 Changed 10 years ago 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).

comment:2 Changed 10 years ago by chrisz

  • Status changed from closed to reopened
  • Resolution fixed deleted

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

comment:3 Changed 10 years ago 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.

Note: See TracTickets for help on using tickets.