source: cows_wps/trunk/cows_wps/websetup.py @ 7115

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cows_wps/trunk/cows_wps/websetup.py@7115
Revision 7115, 1.0 KB checked in by astephen, 10 years ago (diff)

more work on admin interface etc.

Line 
1"""Setup the foo application"""
2import logging, sys
3
4import pkg_resources
5
6from paste.deploy import appconfig
7from pylons import config
8
9
10from sqlalchemy import create_engine
11
12from cows_wps.wsgiapp import load_environment
13from cows_wps.model.orm import tables
14
15log = logging.getLogger(__name__)
16
17# A hook used by the test framework
18prompt_for_db_reset = True
19
20def setup_config(command, filename, section, vars):
21    """Place any commands to setup foo here"""
22    conf = appconfig('config:' + filename)
23    load_environment(conf.global_conf, conf.local_conf, set_env = False)
24
25    from cows_wps.model.session import engine
26
27    print 'Initialising WPS database %s' % engine.url
28    if prompt_for_db_reset:
29        print 'Would you like to drop all tables? ',
30        p = sys.stdin.readline().strip()
31        if p[0] in 'yY':
32            print 'Dropping tables ...'
33            tables.metadata.drop_all(engine)
34    print 'Creating tables in database %s ...' % engine.url
35
36    tables.metadata.create_all(engine)
37#    tables.admin.create(engine)
38    print 'Done'
39   
Note: See TracBrowser for help on using the repository browser.