# HG changeset patch # User Marcin Kuzminski # Date 2010-06-30 22:57:45 # Node ID 0e87466a117e6d29f16d54561f565d97f0ed089a # Parent 674e0085ccc75af46fe6236616f44bd79e12fb47 updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -8,4 +8,6 @@ syntax: regexp 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 diff --git a/README.rst b/README.rst --- a/README.rst +++ b/README.rst @@ -40,16 +40,15 @@ Installation 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 diff --git a/repositories.config b/pylons_app/config/repositories.config_tmpl rename from repositories.config rename to pylons_app/config/repositories.config_tmpl --- a/repositories.config +++ b/pylons_app/config/repositories.config_tmpl @@ -11,4 +11,4 @@ baseurl = / [paths] #this path should point to mercurial repositories remeber about '*' at the end -/ = /home/marcink/python_workspace/* +/ = %(repo_location)s diff --git a/pylons_app/lib/db_manage.py b/pylons_app/lib/db_manage.py --- a/pylons_app/lib/db_manage.py +++ b/pylons_app/lib/db_manage.py @@ -27,6 +27,7 @@ database managment and creation for hg a 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) @@ -41,7 +42,7 @@ 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): @@ -85,10 +86,10 @@ class DbManage(object): #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 @@ -131,13 +132,3 @@ class DbManage(object): except: self.sa.rollback() raise - - - -if __name__ == '__main__': - dbmanage = DbManage(log_sql=True) - dbmanage.create_tables(override=True) - dbmanage.admin_prompt() - dbmanage.create_permissions() - - diff --git a/pylons_app/websetup.py b/pylons_app/websetup.py --- a/pylons_app/websetup.py +++ b/pylons_app/websetup.py @@ -1,9 +1,49 @@ """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) +