Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update

  • Loading branch information...
commit d837b1e90ed7baad290e6a861ae28aea052b80f9 1 parent 97dc610
@virhilo virhilo authored
View
5 setup.py
@@ -27,7 +27,7 @@
raise RuntimeError('This application requires Python 2.6+')
setup(name='shootout',
- version='0.2.2',
+ version='0.2.3',
description='A generic idea discussion and rating app (Pyramid sample)',
long_description=README + '\n\n' + CHANGES,
classifiers=[
@@ -53,7 +53,8 @@
entry_points="""\
[paste.app_factory]
main = shootout:main
+ [console_scripts]
+ initialize_shootout_db = shootout.scripts.initializedb:main
""",
- paster_plugins=['pyramid'],
)
View
3  shootout/__init__.py
@@ -6,14 +6,11 @@
from sqlalchemy import engine_from_config
-from shootout.models import initialize_sql
-
def main(global_config, **settings): # pragma: no cover
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
- initialize_sql(engine)
session_factory = session_factory_from_settings(settings)
View
6 shootout/models.py
@@ -203,9 +203,3 @@ class RootFactory(object):
def __init__(self, request):
pass # pragma: no cover
-
-def initialize_sql(engine): # pragma: no cover
- DBSession.configure(bind=engine)
- Base.metadata.bind = engine
- Base.metadata.create_all(engine)
-
View
1  shootout/scripts/__init__.py
@@ -0,0 +1 @@
+#package
View
26 shootout/scripts/initializedb.py
@@ -0,0 +1,26 @@
+import os
+import sys
+import transaction
+
+from sqlalchemy import engine_from_config
+
+from pyramid.paster import get_appsettings, setup_logging
+
+from shootout.models import DBSession, Base
+
+def usage(argv):
+ cmd = os.path.basename(argv[0])
+ print('usage: %s <config_uri>\n'
+ '(example: "%s development.ini")' % (cmd, cmd))
+ sys.exit(1)
+
+def main(argv=sys.argv):
+ if len(argv) != 2:
+ usage(argv)
+ config_uri = argv[1]
+ setup_logging(config_uri)
+ settings = get_appsettings(config_uri)
+ engine = engine_from_config(settings, 'sqlalchemy.')
+ DBSession.configure(bind=engine)
+ Base.metadata.create_all(engine)
+
Please sign in to comment.
Something went wrong with that request. Please try again.