Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def init_model(engine):
"""Call me before using any of the tables or classes in the model."""

{{if sqlalchemy}}
DBSession.remove()
DBSession.configure(bind=engine)

# If you are using reflection to introspect your database and create
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from nose.tools import eq_

{{if sqlalchemy}}
import transaction

from {{package}}.model import DBSession
{{elif ming}}
from tg import config
Expand Down Expand Up @@ -64,7 +66,7 @@ class ModelTest(object):
# On MongoDB drop database
datastore.conn.drop_database(datastore.db)
{{elif sqlalchemy}}
DBSession.rollback()
transaction.abort()
{{endif}}
raise

Expand All @@ -79,7 +81,7 @@ class ModelTest(object):
# On MongoDB drop database
datastore.conn.drop_database(datastore.db)
{{elif sqlalchemy}}
DBSession.rollback()
transaction.abort()
{{endif}}

def do_get_dependencies(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def bootstrap(command, conf, vars):
{{if auth == "sqlalchemy"}}
from sqlalchemy.exc import IntegrityError
try:
transaction.begin()
u = model.User()
u.user_name = 'manager'
u.display_name = 'Example manager'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def setup_schema(command, conf, vars):
from {{package}} import model
# <websetup.websetup.schema.after.model.import>

transaction.begin()
# <websetup.websetup.schema.before.metadata.create_all>
print("Creating tables")
model.metadata.create_all(bind=config['tg.app_globals'].sa_engine)
Expand All @@ -32,4 +33,4 @@ def setup_schema(command, conf, vars):
alembic_cfg.set_main_option("sqlalchemy.url", config['sqlalchemy.url'])
import alembic.command
alembic.command.stamp(alembic_cfg, "head")
{{endif}}
{{endif}}