changeset 327:0e87466a117e

updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 01 Jul 2010 00:57:45 +0200
parents 674e0085ccc7
children cec5cbc956c0
files .hgignore README.rst pylons_app/config/repositories.config_tmpl pylons_app/lib/db_manage.py pylons_app/websetup.py repositories.config
diffstat 6 files changed, 69 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Thu Jul 01 00:04:59 2010 +0200
+++ b/.hgignore	Thu Jul 01 00:57:45 2010 +0200
@@ -8,4 +8,6 @@
 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
--- a/README.rst	Thu Jul 01 00:04:59 2010 +0200
+++ b/README.rst	Thu Jul 01 00:57:45 2010 +0200
@@ -40,16 +40,15 @@
    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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pylons_app/config/repositories.config_tmpl	Thu Jul 01 00:57:45 2010 +0200
@@ -0,0 +1,14 @@
+[hooks]
+#to do push with autoupdate
+changegroup = hg update >&2
+
+[web]
+#for http requests push ssl to false
+push_ssl = false
+allow_archive = gz zip bz2
+allow_push = *
+baseurl = /
+
+[paths]
+#this path should point to mercurial repositories remeber about '*' at the end
+/ = %(repo_location)s
--- a/pylons_app/lib/db_manage.py	Thu Jul 01 00:04:59 2010 +0200
+++ b/pylons_app/lib/db_manage.py	Thu Jul 01 00:57:45 2010 +0200
@@ -27,6 +27,7 @@
 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.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 @@
         #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 @@
             except:
                 self.sa.rollback()
                 raise
-        
-        
-        
-if __name__ == '__main__':
-    dbmanage = DbManage(log_sql=True)
-    dbmanage.create_tables(override=True)
-    dbmanage.admin_prompt()
-    dbmanage.create_permissions()  
-
-
--- a/pylons_app/websetup.py	Thu Jul 01 00:04:59 2010 +0200
+++ b/pylons_app/websetup.py	Thu Jul 01 00:57:45 2010 +0200
@@ -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)
+
--- a/repositories.config	Thu Jul 01 00:04:59 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-[hooks]
-#to do push with autoupdate
-changegroup = hg update >&2
-
-[web]
-#for http requests push ssl to false
-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/*