##// 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 from pylons_app.lib.auth import get_crypt_password
34 from pylons_app.lib.auth import get_crypt_password
35 from pylons_app.model import init_model
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 from pylons_app.model.meta import Session, Base
37 from pylons_app.model.meta import Session, Base
38 from sqlalchemy.engine import create_engine
38 from sqlalchemy.engine import create_engine
39 import logging
39 import logging
@@ -81,7 +81,7 b' class DbManage(object):'
81 self.create_user(username, password, True)
81 self.create_user(username, password, True)
82
82
83 def config_prompt(self):
83 def config_prompt(self):
84 log.info('Seting up repositories.config')
84 log.info('Setting up repositories config')
85
85
86
86
87 path = raw_input('Specify valid full path to your repositories'
87 path = raw_input('Specify valid full path to your repositories'
@@ -122,6 +122,10 b' class DbManage(object):'
122 paths.ui_value = os.path.join(path, '*')
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 try:
129 try:
126 self.sa.add(hooks)
130 self.sa.add(hooks)
127 self.sa.add(web1)
131 self.sa.add(web1)
@@ -129,6 +133,7 b' class DbManage(object):'
129 self.sa.add(web3)
133 self.sa.add(web3)
130 self.sa.add(web4)
134 self.sa.add(web4)
131 self.sa.add(paths)
135 self.sa.add(paths)
136 self.sa.add(hgsettings)
132 self.sa.commit()
137 self.sa.commit()
133 except:
138 except:
134 self.sa.rollback()
139 self.sa.rollback()
@@ -28,7 +28,8 b' import os'
28 import logging
28 import logging
29 from mercurial import ui, config, hg
29 from mercurial import ui, config, hg
30 from mercurial.error import RepoError
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 log = logging.getLogger(__name__)
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 @cache_region('super_short_term', 'cached_hg_ui')
81 @cache_region('super_short_term', 'cached_hg_ui')
81 def get_hg_ui_cached():
82 def get_hg_ui_cached():
82 from pylons_app.model.meta import Session
83 sa = Session()
83 sa = Session()
84 return sa.query(HgAppUi).all()
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 def make_ui(read_from='file', path=None, checkpaths=True):
93 def make_ui(read_from='file', path=None, checkpaths=True):
87 """
94 """
88 A function that will read python rc files or database
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 def set_hg_app_config(config):
138 def set_hg_app_config(config):
132 config['hg_app_auth_realm'] = 'realm'
139 hgsettings = get_hg_settings()
133 config['hg_app_name'] = 'app name'
140 config['hg_app_auth_realm'] = hgsettings.app_auth_realm
141 config['hg_app_name'] = hgsettings.app_title
134
142
135 def invalidate_cache(name, *args):
143 def invalidate_cache(name, *args):
136 """Invalidates given name cache"""
144 """Invalidates given name cache"""
General Comments 0
You need to be logged in to leave comments. Login now