adding sqlalchemy-migrate glue

* add a product and producttype table (addresses #1)
 * add a person table and reference to customers table (fixes #8)
 * use sqlalchemy-migrate's API to setup database and add
   configuration for the sqlalchemy-migrate calls to development.ini
   and the paste_deploy template (fixes #7)


git-svn-id: file:///var/www/wwwusers/usr01/svn/pyalchemybiz/trunk@7 389c73d4-bf09-4d3d-a15e-f94a37d0667a
This commit is contained in:
Jan Dittberner 2008-10-05 21:02:10 +00:00
parent ab91d92af3
commit 1228fcef3c
16 changed files with 183 additions and 12 deletions

View file

@ -3,6 +3,9 @@ import os
from pylons import config
from sqlalchemy import engine_from_config
from sqlalchemy.exceptions import NoSuchTableError
from migrate.versioning.api import db_version
from pyalchemybiz.model import init_model
import pyalchemybiz.lib.app_globals as app_globals
@ -35,4 +38,17 @@ def load_environment(global_conf, app_conf):
# any Pylons config options)
engine = \
engine_from_config(config, 'sqlalchemy.default.')
init_model(engine)
try:
init_model(engine)
except Exception:
# special handling for calls in websetup.py
import inspect
frame = inspect.currentframe()
try:
functions = [current[3] for current in \
inspect.getouterframes(frame)]
if functions[1] != 'setup_config':
raise
finally:
del frame