Changeset - bb8f45f6d8f9
[Not reviewed]
default
0 2 0
Marcin Kuzminski - 15 years ago 2010-07-14 12:50:12
marcin@python-works.com
updated hg-app db manage and global settings
2 files changed with 19 insertions and 6 deletions:
0 comments (0 inline, 0 general)
pylons_app/lib/db_manage.py
Show inline comments
 
@@ -33,7 +33,7 @@ sys.path.append(ROOT)
 

	
 
from pylons_app.lib.auth import get_crypt_password
 
from pylons_app.model import init_model
 
from pylons_app.model.db import User, Permission, HgAppUi
 
from pylons_app.model.db import User, Permission, HgAppUi, HgAppSettings
 
from pylons_app.model.meta import Session, Base
 
from sqlalchemy.engine import create_engine
 
import logging
 
@@ -81,7 +81,7 @@ class DbManage(object):
 
        self.create_user(username, password, True)
 
    
 
    def config_prompt(self):
 
        log.info('Seting up repositories.config')
 
        log.info('Setting up repositories config')
 
        
 
        
 
        path = raw_input('Specify valid full path to your repositories'
 
@@ -122,6 +122,10 @@ class DbManage(object):
 
        paths.ui_value = os.path.join(path, '*')
 
        
 
        
 
        hgsettings = HgAppSettings()
 
        hgsettings.app_auth_realm = 'hg-app authentication'
 
        hgsettings.app_title = 'hg-app'
 
        
 
        try:
 
            self.sa.add(hooks)
 
            self.sa.add(web1)
 
@@ -129,6 +133,7 @@ class DbManage(object):
 
            self.sa.add(web3)
 
            self.sa.add(web4)
 
            self.sa.add(paths)
 
            self.sa.add(hgsettings)
 
            self.sa.commit()
 
        except:
 
            self.sa.rollback()
pylons_app/lib/utils.py
Show inline comments
 
@@ -28,7 +28,8 @@ import os
 
import logging
 
from mercurial import ui, config, hg
 
from mercurial.error import RepoError
 
from pylons_app.model.db import Repository, User, HgAppUi
 
from pylons_app.model.db import Repository, User, HgAppUi, HgAppSettings
 
from pylons_app.model.meta import Session
 
log = logging.getLogger(__name__)
 

	
 

	
 
@@ -79,10 +80,16 @@ def check_repo(repo_name, base_path, ver
 

	
 
@cache_region('super_short_term', 'cached_hg_ui')
 
def get_hg_ui_cached():
 
    from pylons_app.model.meta import Session
 
    sa = Session()
 
    return sa.query(HgAppUi).all()    
 

	
 
def get_hg_settings():
 
    sa = Session()
 
    ret = sa.query(HgAppSettings).scalar()
 
    if not ret:
 
        raise Exception('Could not get application settings !')
 
    return ret
 
    
 
def make_ui(read_from='file', path=None, checkpaths=True):        
 
    """
 
    A function that will read python rc files or database
 
@@ -129,8 +136,9 @@ def make_ui(read_from='file', path=None,
 

	
 

	
 
def set_hg_app_config(config):
 
    config['hg_app_auth_realm'] = 'realm'
 
    config['hg_app_name'] = 'app name'
 
    hgsettings = get_hg_settings()
 
    config['hg_app_auth_realm'] = hgsettings.app_auth_realm
 
    config['hg_app_name'] = hgsettings.app_title
 

	
 
def invalidate_cache(name, *args):
 
    """Invalidates given name cache"""
0 comments (0 inline, 0 general)