Changeset - 0e87466a117e
[Not reviewed]
default
1 4 1
Marcin Kuzminski - 15 years ago 2010-07-01 00:57:45
marcin@python-works.com
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
5 files changed with 56 insertions and 24 deletions:
0 comments (0 inline, 0 general)
.hgignore
Show inline comments
 
@@ -5,7 +5,9 @@ syntax: regexp
 
^\.settings$
 
syntax: regexp
 
^\.project$
 
syntax: regexp
 
^\.pydevproject$
 
syntax: regexp
 
^hg_app\.db$
 
\ No newline at end of file
 
^hg_app\.db$
 
syntax: regexp
 
^repositories\.config$
 
\ No newline at end of file
README.rst
Show inline comments
 
@@ -37,21 +37,20 @@ Fully customizable, with authentication,
 
Installation
 
-------------
 
.. note::
 
   I recomend to install tip version of vcs while the app is in beta mode.
 
   
 
   
 
- create new virtualenv and activate it
 
- create new virtualenv and activate it - highly recommend that you use separate
 
  virtual-env for whole application
 
- download hg app from default (not demo) branch from bitbucket and run 
 
  'python setup.py install' this will install all required dependencies needed
 
- goto pylons_app/lib and run python db_manage.py it should create all 
 
  needed tables and an admin account. You can play with this file if you wish to
 
  use different db than sqlite 
 
- edit file repositories.config and change the [paths] where you keep your
 
  mercurial repositories, remember about permissions for accessing this dir by
 
  hg app.
 
- run paster serve development.ini 
 
- run paster setup-app production.ini it should create all needed tables 
 
  and an admin account. Also it will create repositories.config for mercurial 
 
  commands, remember that the given path for mercurial repositories must be write
 
  accessible for the application
 
- run paster serve development.ini - or you can use manage-hg_app script.
 
  the app should be available at the 127.0.0.1:5000
 
- use admin account you created to login.
 
- default permissions on each repository is read, and owner is admin. So remember
 
  to update those.
 
     
 
\ No newline at end of file
pylons_app/config/repositories.config_tmpl
Show inline comments
 
file renamed from repositories.config to pylons_app/config/repositories.config_tmpl
 
@@ -8,7 +8,7 @@ push_ssl = false
 
allow_archive = gz zip bz2
 
allow_push = *
 
baseurl = /
 

	
 
[paths]
 
#this path should point to mercurial repositories remeber about '*' at the end
 
/ = /home/marcink/python_workspace/*
 
/ = %(repo_location)s
pylons_app/lib/db_manage.py
Show inline comments
 
@@ -24,12 +24,13 @@ database managment and creation for hg a
 
@author: marcink
 
"""
 

	
 
from os.path import dirname as dn, join as jn
 
import os
 
import sys
 
import uuid
 
ROOT = dn(dn(dn(os.path.realpath(__file__))))
 
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
 
@@ -38,13 +39,13 @@ from sqlalchemy.engine import create_eng
 
import logging
 

	
 
log = logging.getLogger('db manage')
 
log.setLevel(logging.DEBUG)
 
console_handler = logging.StreamHandler()
 
console_handler.setFormatter(logging.Formatter("%(asctime)s.%(msecs)03d" 
 
                                    " %(levelname)-5.5s [%(name)s] %(message)s"))
 
                                  " %(levelname)-5.5s [%(name)s] %(message)s"))
 
log.addHandler(console_handler)
 

	
 
class DbManage(object):
 
    def __init__(self, log_sql):
 
        self.dbname = 'hg_app.db'
 
        dburi = 'sqlite:////%s' % jn(ROOT, self.dbname)
 
@@ -82,16 +83,16 @@ class DbManage(object):
 
    def create_user(self, username, password, admin=False):
 
        
 
        log.info('creating default user')
 
        #create default user for handling default permissions.
 
        def_user = User()
 
        def_user.username = 'default'
 
        def_user.password = 'default'
 
        def_user.password = get_crypt_password(str(uuid.uuid1())[:8])
 
        def_user.name = 'default'
 
        def_user.lastname = 'default'
 
        def_user.email = 'default@default'
 
        def_user.email = 'default@default.com'
 
        def_user.admin = False
 
        def_user.active = False
 
        
 
        self.sa.add(def_user)
 
        
 
        log.info('creating administrator user %s', username)
 
@@ -128,16 +129,6 @@ class DbManage(object):
 
            try:
 
                self.sa.add(new_perm)
 
                self.sa.commit()
 
            except:
 
                self.sa.rollback()
 
                raise
 
        
 
        
 
        
 
if __name__ == '__main__':
 
    dbmanage = DbManage(log_sql=True)
 
    dbmanage.create_tables(override=True)
 
    dbmanage.admin_prompt()
 
    dbmanage.create_permissions()  
 

	
 

	
pylons_app/websetup.py
Show inline comments
 
"""Setup the pylons_app application"""
 

	
 
from os.path import dirname as dn, join as jn
 
from pylons_app.config.environment import load_environment
 
from pylons_app.lib.db_manage import DbManage
 
import logging
 
from pylons_app.config.environment import load_environment
 
import os
 
import sys
 

	
 
log = logging.getLogger(__name__)
 

	
 
ROOT = dn(dn(os.path.realpath(__file__)))
 
sys.path.append(ROOT)
 

	
 

	
 
def setup_repository():
 
    log.info('Seting up repositories.config')
 
    fname = 'repositories.config'
 
    
 
    try:
 
        tmpl = open(jn(ROOT, 'pylons_app', 'config', 'repositories.config_tmpl')).read()
 
    except IOError:
 
        raise
 
    
 
    path = raw_input('Specify valid full path to your repositories'
 
                    ' you can change this later in repositories.config file:')
 
    
 
    if not os.path.isdir(path):
 
        log.error('You entered wrong path')
 
        sys.exit()
 
    
 
    
 
    path = jn(path, '*') 
 
    dest_path = jn(ROOT, fname)
 
    f = open(dest_path, 'wb')
 
    f.write(tmpl % {'repo_location':path})
 
    f.close()
 
    log.info('created repositories.config in %s', dest_path)
 
        
 

	
 
def setup_app(command, conf, vars):
 
    """Place any commands to setup pylons_app here"""
 
    setup_repository()
 
    dbmanage = DbManage(log_sql=True)
 
    dbmanage.create_tables(override=True)
 
    dbmanage.admin_prompt()
 
    dbmanage.create_permissions()
 
    load_environment(conf.global_conf, conf.local_conf)
 

	
0 comments (0 inline, 0 general)