##// END OF EJS Templates
updated hg-app db manage and global settings
marcink -
r345:bb8f45f6 default
parent child Browse files
Show More
@@ -33,7 +33,7 b' sys.path.append(ROOT)'
33 33
34 34 from pylons_app.lib.auth import get_crypt_password
35 35 from pylons_app.model import init_model
36 from pylons_app.model.db import User, Permission, HgAppUi
36 from pylons_app.model.db import User, Permission, HgAppUi, HgAppSettings
37 37 from pylons_app.model.meta import Session, Base
38 38 from sqlalchemy.engine import create_engine
39 39 import logging
@@ -81,7 +81,7 b' class DbManage(object):'
81 81 self.create_user(username, password, True)
82 82
83 83 def config_prompt(self):
84 log.info('Seting up repositories.config')
84 log.info('Setting up repositories config')
85 85
86 86
87 87 path = raw_input('Specify valid full path to your repositories'
@@ -122,6 +122,10 b' class DbManage(object):'
122 122 paths.ui_value = os.path.join(path, '*')
123 123
124 124
125 hgsettings = HgAppSettings()
126 hgsettings.app_auth_realm = 'hg-app authentication'
127 hgsettings.app_title = 'hg-app'
128
125 129 try:
126 130 self.sa.add(hooks)
127 131 self.sa.add(web1)
@@ -129,6 +133,7 b' class DbManage(object):'
129 133 self.sa.add(web3)
130 134 self.sa.add(web4)
131 135 self.sa.add(paths)
136 self.sa.add(hgsettings)
132 137 self.sa.commit()
133 138 except:
134 139 self.sa.rollback()
@@ -28,7 +28,8 b' import os'
28 28 import logging
29 29 from mercurial import ui, config, hg
30 30 from mercurial.error import RepoError
31 from pylons_app.model.db import Repository, User, HgAppUi
31 from pylons_app.model.db import Repository, User, HgAppUi, HgAppSettings
32 from pylons_app.model.meta import Session
32 33 log = logging.getLogger(__name__)
33 34
34 35
@@ -79,10 +80,16 b' def check_repo(repo_name, base_path, ver'
79 80
80 81 @cache_region('super_short_term', 'cached_hg_ui')
81 82 def get_hg_ui_cached():
82 from pylons_app.model.meta import Session
83 83 sa = Session()
84 84 return sa.query(HgAppUi).all()
85 85
86 def get_hg_settings():
87 sa = Session()
88 ret = sa.query(HgAppSettings).scalar()
89 if not ret:
90 raise Exception('Could not get application settings !')
91 return ret
92
86 93 def make_ui(read_from='file', path=None, checkpaths=True):
87 94 """
88 95 A function that will read python rc files or database
@@ -129,8 +136,9 b" def make_ui(read_from='file', path=None,"
129 136
130 137
131 138 def set_hg_app_config(config):
132 config['hg_app_auth_realm'] = 'realm'
133 config['hg_app_name'] = 'app name'
139 hgsettings = get_hg_settings()
140 config['hg_app_auth_realm'] = hgsettings.app_auth_realm
141 config['hg_app_name'] = hgsettings.app_title
134 142
135 143 def invalidate_cache(name, *args):
136 144 """Invalidates given name cache"""
General Comments 0
You need to be logged in to leave comments. Login now