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 #2013 (closed enhancement: fixed)

Opened 9 years ago

Last modified 8 years ago

[PATCH] Add an (example) database bootstrap command to commands.py in quickstart template

Reported by: Chris Arndt Owned by: Chris Arndt
Priority: normal Milestone: 1.1
Component: Quickstart Templates Version: 1.1 HEAD
Severity: normal Keywords: quickstart, bootstrap, needs tests, needs documentation
Cc:

Description

I have written an example command.py that provides a "bootstrap" function for a console script "bootstrap-<yourpkg>", which creates all tables and optionally creates a user.

 http://paste.turbogears.org/paste/10038

The example is SQLAlchemy, but I have also written a patch against current TG 1.1 HEAD that adds support for this in commands.py in the default quickstart template and which also works for SQLObject-based projects.

Would this be something that should be added to the default quickstart template or will this make the code in commands.py too complex?

Attachments

qs-bootstrap-command.diff Download (6.7 KB) - added by Chris Arndt 9 years ago.
qs-bootstrap-new.diff Download (10.9 KB) - added by Chris Arndt 9 years ago.
Updated patch with Elixir support and moving model bootstrap functions to model.py

Change History

Changed 9 years ago by Chris Arndt

comment:1 Changed 9 years ago by faide

+1

comment:2 Changed 9 years ago by Chris Arndt

See ticket #1793 for the related documentation task.

comment:3 Changed 9 years ago by faide

  • Milestone changed from 1.1 to 1.1 beta 2

comment:4 Changed 9 years ago by faide

  • Milestone changed from 1.1 beta 2 to 1.1

Changed 9 years ago by Chris Arndt

Updated patch with Elixir support and moving model bootstrap functions to model.py

comment:5 Changed 9 years ago by Chris Arndt

  • Status changed from new to assigned

I attached an updated patch that now, in conjunction with r5736, provides support for Elixir models as well (but see #2047) and moves the model bootstrap functions to the model.py file.

Despite of  ideas on the mailing list to provide a framework for moving the boostrap function into the TG core and provide a framework for adding user functions to run on bootstrapping, I now opted for just adding the bootstrap logic to the code generated by the quickstart templates, because I think that the data bootstrapping is highly specific to each application, so it should be user customizable to the maximum. Having the bootstrapping logic directly in the application code is IMHO the best way to do this.

One thing that could be put in the turbogears package though is the code to create all database tables, since this is already used/needed in different places in TurboGears, e.g. in testutil (and could be used in command.sa_command as well). I'm not sure where to put this best. turbogears.util and turbogears.database seem both valid candidates. Probably we should open another ticket for this issue.

comment:6 Changed 9 years ago by faide

+1 for the new ticket...

comment:7 Changed 9 years ago by faide

+1 for applying this

comment:8 Changed 9 years ago by Chris Arndt

  • Keywords tests, documentation added; review removed

Applied in r5756. Could use some test in the 'test' package in the quickstart templates. Also needs to be documented, so leaving this open.

comment:9 Changed 8 years ago by Chris Arndt

I opened a separate ticket (#2365) for the documentation task.

comment:10 Changed 8 years ago by Chris Arndt

  • Status changed from assigned to closed
  • Resolution set to fixed

Tests added in r6673.

Note: See TracTickets for help on using tickets.