annotate pylons_app/websetup.py @ 513:e94f4e54dc03

tests fix, put vcs testing tarball
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 11 Sep 2010 03:35:33 +0200
parents 7c978511c951
children 6b934c9607e7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
1 """Setup the pylons_app application"""
345
0e87466a117e updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
2
0e87466a117e updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
3 from os.path import dirname as dn, join as jn
0e87466a117e updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
4 from pylons_app.config.environment import load_environment
0e87466a117e updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
5 from pylons_app.lib.db_manage import DbManage
501
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
6 import datetime
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
7 from time import mktime
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
8 import logging
345
0e87466a117e updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
9 import os
0e87466a117e updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
10 import sys
513
e94f4e54dc03 tests fix, put vcs testing tarball
Marcin Kuzminski <marcin@python-works.com>
parents: 501
diff changeset
11 import tarfile
e94f4e54dc03 tests fix, put vcs testing tarball
Marcin Kuzminski <marcin@python-works.com>
parents: 501
diff changeset
12
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
13 log = logging.getLogger(__name__)
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
14
345
0e87466a117e updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
15 ROOT = dn(dn(os.path.realpath(__file__)))
0e87466a117e updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
16 sys.path.append(ROOT)
0e87466a117e updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
17
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
18 def setup_app(command, conf, vars):
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
19 """Place any commands to setup pylons_app here"""
501
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
20 log_sql = True
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
21 tests = False
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
22
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
23 dbname = os.path.split(conf['sqlalchemy.db1.url'])[-1]
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
24 filename = os.path.split(conf.filename)[-1]
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
25
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
26 if filename == 'tests.ini':
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
27 uniq_suffix = str(int(mktime(datetime.datetime.now().timetuple())))
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
28 REPO_TEST_PATH = '/tmp/hg_app_test_%s' % uniq_suffix
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
29
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
30 if not os.path.isdir(REPO_TEST_PATH):
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
31 os.mkdir(REPO_TEST_PATH)
513
e94f4e54dc03 tests fix, put vcs testing tarball
Marcin Kuzminski <marcin@python-works.com>
parents: 501
diff changeset
32 cur_dir = dn(os.path.abspath(__file__))
e94f4e54dc03 tests fix, put vcs testing tarball
Marcin Kuzminski <marcin@python-works.com>
parents: 501
diff changeset
33 tar = tarfile.open(jn(cur_dir,'tests',"vcs_test.tar.gz"))
e94f4e54dc03 tests fix, put vcs testing tarball
Marcin Kuzminski <marcin@python-works.com>
parents: 501
diff changeset
34 tar.extractall(REPO_TEST_PATH)
e94f4e54dc03 tests fix, put vcs testing tarball
Marcin Kuzminski <marcin@python-works.com>
parents: 501
diff changeset
35 tar.close()
501
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
36
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
37 tests = True
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
38
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
39 dbmanage = DbManage(log_sql, dbname, tests)
345
0e87466a117e updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
40 dbmanage.create_tables(override=True)
501
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
41 dbmanage.config_prompt(REPO_TEST_PATH)
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
42 dbmanage.create_default_user()
345
0e87466a117e updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
43 dbmanage.admin_prompt()
0e87466a117e updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
44 dbmanage.create_permissions()
453
3ed2d46a2ca7 permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents: 391
diff changeset
45 dbmanage.populate_default_permissions()
391
ec7b76d4bda4 Added initial query skipp when seting up the app.
Marcin Kuzminski <marcin@python-works.com>
parents: 364
diff changeset
46 load_environment(conf.global_conf, conf.local_conf, initial=True)
345
0e87466a117e updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
47