Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


#9 Refactor database configuration


This was ticket #1813 in the old Trac, reported by Chris Arndt in 2008.

The database configuration needs the following refactorings:

  1. Replace backslashes (windows paths) in current_dir_uri (in config.py)
  2. New function "get_dburi" or "get_db_config" (in database.py) that
    • Chooses the correct config setting to use (sqlobject. vs sqlalchemy.)
    • Converts : into | for SQLObject
    • Converts | into : for SQLAlchemy
    • Handles 'notrans_' (but see "open questions" below)
  3. Use 'get_dburi' in
    • database.bind_metadata
    • database.AutoConnectHub
    • database.PackageHub
    • command.base.CommandWithDB
    • command.base.SQL.run
    • command.base.Shell.run
    • command.sacommand.create
    • command.quickstart.update.run
    • Anywhere else?
  4. Test multiple dburis for SQLAlchemy and write unit tests for this feature. Possibly change the way multiple database connections are handled completely, since current support does not support different ORMs.
  5. Open questions:
    • Where to handle "no_trans" best?
    • Support "notrans_" for SQLAlchemy too?
    • Continue to support dburis of the form <packagename>.dburi? If yes, how to distinguish between SQLObject and SQLAlchemy?
    • What should get_dburi return? A string or a dict?

See also the old Trac ticket #2048 for another reason the database config needs to be improved.


  • Some comments 04/25/08:

    • Point 1 can be realized with the urllib.pathname2url() function.
    • I think dburis should not be associated with package names, but just with names. The PackageHub class should become NamedHub. The reference to packages was confusing. Note that "packagename" here did not refer to the ORM package "sqlobject" or "sqlalchemy", but was supposed to refer to a subpackage of the app using a different database connection.
      • We should decide whether the setting is called [<name>].dburi or [<name>].sql{alchemy|object}.dburi. Currently, the default dburi has the sql{alchemy|object} distinguisher, but the named dburis don't.
      • See also thread in tg-trunk.
  • Chris Arndt, 03/08/11: All the improvements this ticket suggests are still not implemented and desireable.



Cancel   Add attachments