changeset 1216:8363b0d20c41

fixes for stable
author Marcin Kuzminski <marcin@python-works.com>
date Tue, 05 Apr 2011 18:01:19 +0200
parents 8a153dba7033
children a3b2b4b4e440
files README.rst docs/changelog.rst rhodecode/lib/db_manage.py rhodecode/model/scm.py rhodecode/templates/base/base.html
diffstat 5 files changed, 109 insertions(+), 83 deletions(-) [+]
line wrap: on
line diff
--- a/README.rst	Tue Apr 05 17:34:04 2011 +0200
+++ b/README.rst	Tue Apr 05 18:01:19 2011 +0200
@@ -31,12 +31,20 @@
 Source code
 -----------
 
-The latest source for RhodeCode can be obtained from official RhodeCode instance
+The latest sources can be obtained from official RhodeCode instance
 https://hg.rhodecode.org 
 
-Rarely updated source code and issue tracker is available at bitbucket
+
+MIRRORS:
+
+Issue tracker and sources at bitbucket_
+
 http://bitbucket.org/marcinkuzminski/rhodecode
 
+Sources at github_
+
+https://github.com/marcinkuzminski/rhodecode
+
 Installation
 ------------
 
@@ -48,7 +56,7 @@
 
 - Has it's own middleware to handle mercurial_ protocol requests. 
   Each request can be logged and authenticated.
-- Runs on threads unlike hgweb. You can make multiple pulls/pushes simultaneous. 
+- Runs on threads unlike hgweb. You can make multiple pulls/pushes simultaneous.
   Supports http/https and LDAP
 - Full permissions (private/read/write/admin) and authentication per project. 
   One account for web interface and mercurial_ push/pull/clone operations.
@@ -94,7 +102,7 @@
 License
 -------
 
-``RhodeCode`` is released under the GPL_ license.
+``RhodeCode`` is released under the GPLv3 license.
 
 
 Mailing group Q&A
@@ -117,16 +125,17 @@
    make html
 
 (You need to have sphinx_ installed to build the documentation. If you don't
-have sphinx_ installed you can install it via the command: ``easy_install sphinx``)
+have sphinx_ installed you can install it via the command: 
+``easy_install sphinx``)
  
 .. _virtualenv: http://pypi.python.org/pypi/virtualenv
 .. _python: http://www.python.org/
 .. _sphinx: http://sphinx.pocoo.org/
 .. _mercurial: http://mercurial.selenic.com/
 .. _bitbucket: http://bitbucket.org/
+.. _github: http://github.com/
 .. _subversion: http://subversion.tigris.org/
 .. _git: http://git-scm.com/
 .. _celery: http://celeryproject.org/
 .. _Sphinx: http://sphinx.pocoo.org/
-.. _GPL: http://www.gnu.org/licenses/gpl.html
 .. _vcs: http://pypi.python.org/pypi/vcs
\ No newline at end of file
--- a/docs/changelog.rst	Tue Apr 05 17:34:04 2011 +0200
+++ b/docs/changelog.rst	Tue Apr 05 18:01:19 2011 +0200
@@ -4,7 +4,7 @@
 =========
 
 
-1.1.7 (**2011-03-23**)
+1.1.8 (**2011-04-XX**)
 ======================
 
 news
@@ -15,6 +15,8 @@
 
 - fixed #140 freeze of python dateutil library, since new version is python2.x
   incompatible
+- setup-app will check for write permission in given path
+
 
 1.1.7 (**2011-03-23**)
 ======================
--- a/rhodecode/lib/db_manage.py	Tue Apr 05 17:34:04 2011 +0200
+++ b/rhodecode/lib/db_manage.py	Tue Apr 05 18:01:19 2011 +0200
@@ -5,26 +5,24 @@
 
     Database creation, and setup module for RhodeCode. Used for creation
     of database as well as for migration operations
-    
+
     :created_on: Apr 10, 2010
     :author: marcink
-    :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>    
+    :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>
     :license: GPLv3, see COPYING for more details.
 """
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; version 2
-# of the License or (at your opinion) any later version of the license.
-# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA  02110-1301, USA.
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import os
 import sys
@@ -38,13 +36,14 @@
 from rhodecode.lib.auth import get_crypt_password
 from rhodecode.lib.utils import ask_ok
 from rhodecode.model import init_model
-from rhodecode.model.db import User, Permission, RhodeCodeUi, RhodeCodeSettings, \
-    UserToPerm, DbMigrateVersion
+from rhodecode.model.db import User, Permission, RhodeCodeUi, \
+    RhodeCodeSettings, UserToPerm, DbMigrateVersion
 
 from sqlalchemy.engine import create_engine
 
 log = logging.getLogger(__name__)
 
+
 class DbManage(object):
     def __init__(self, log_sql, dbconf, root, tests=False):
         self.dbname = dbconf.split('/')[-1]
@@ -78,8 +77,6 @@
         meta.Base.metadata.create_all(checkfirst=checkfirst)
         log.info('Created tables for %s', self.dbname)
 
-
-
     def set_db_version(self):
         try:
             ver = DbMigrateVersion()
@@ -93,12 +90,10 @@
             raise
         log.info('db version set to: %s', __dbversion__)
 
+    def upgrade(self):
+        """Upgrades given database schema to given revision following
+        all needed steps, to perform the upgrade
 
-    def upgrade(self):
-        """Upgrades given database schema to given revision following 
-        all needed steps, to perform the upgrade
-        
-        :param revision: revision to upgrade to
         """
 
         from rhodecode.lib.dbmigrate.migrate.versioning import api
@@ -135,7 +130,7 @@
         # UPGRADE STEPS
         #======================================================================
         class UpgradeSteps(object):
-            """Those steps follow schema versions so for example schema 
+            """Those steps follow schema versions so for example schema
             for example schema with seq 002 == step_2 and so on.
             """
 
@@ -162,7 +157,6 @@
                 log.info('Changing ui settings')
                 self.klass.create_ui_settings()
 
-
         upgrade_steps = [0] + range(curr_version + 1, __dbversion__ + 1)
 
         #CALL THE PROPER ORDER OF STEPS TO PERFORM FULL UPGRADE
@@ -170,8 +164,6 @@
             print ('performing upgrade step %s' % step)
             callable = getattr(UpgradeSteps(self), 'step_%s' % step)()
 
-
-
     def fix_repo_paths(self):
         """Fixes a old rhodecode version path into new one without a '*'
         """
@@ -208,15 +200,13 @@
             self.sa.rollback()
             raise
 
-
-
     def admin_prompt(self, second=False):
         if not self.tests:
             import getpass
 
-
             def get_password():
-                password = getpass.getpass('Specify admin password (min 6 chars):')
+                password = getpass.getpass('Specify admin password '
+                                           '(min 6 chars):')
                 confirm = getpass.getpass('Confirm password:')
 
                 if password != confirm:
@@ -241,14 +231,17 @@
             self.create_user(username, password, email, True)
         else:
             log.info('creating admin and regular test users')
-            self.create_user('test_admin', 'test12', 'test_admin@mail.com', True)
-            self.create_user('test_regular', 'test12', 'test_regular@mail.com', False)
-            self.create_user('test_regular2', 'test12', 'test_regular2@mail.com', False)
+            self.create_user('test_admin', 'test12',
+                             'test_admin@mail.com', True)
+            self.create_user('test_regular', 'test12',
+                             'test_regular@mail.com', False)
+            self.create_user('test_regular2', 'test12',
+                             'test_regular2@mail.com', False)
 
     def create_ui_settings(self):
         """Creates ui settings, fills out hooks
         and disables dotencode
-        
+
         """
         #HOOKS
         hooks1_key = 'changegroup.update'
@@ -297,7 +290,6 @@
             self.sa.rollback()
             raise
 
-
     def create_ldap_options(self):
         """Creates ldap settings"""
 
@@ -316,18 +308,39 @@
             self.sa.rollback()
             raise
 
-    def config_prompt(self, test_repo_path=''):
-        log.info('Setting up repositories config')
+    def config_prompt(self, test_repo_path='', retries=3):
+        if retries == 3:
+            log.info('Setting up repositories config')
 
         if not self.tests and not test_repo_path:
             path = raw_input('Specify valid full path to your repositories'
                         ' you can change this later in application settings:')
         else:
             path = test_repo_path
+        path_ok = True
 
+        #check proper dir
         if not os.path.isdir(path):
-            log.error('You entered wrong path: %s', path)
+            path_ok = False
+            log.error('Entered path is not a valid directory: %s [%s/3]',
+                      path, retries)
+
+        #check write access
+        if not os.access(path, os.W_OK):
+            path_ok = False
+
+            log.error('No write permission to given path: %s [%s/3]',
+                      path, retries)
+
+        if retries == 0:
             sys.exit()
+        if path_ok is False:
+            retries -= 1
+            return self.config_prompt(test_repo_path, retries)
+
+        return path
+
+    def create_settings(self, path):
 
         self.create_ui_settings()
 
@@ -357,11 +370,9 @@
         paths.ui_key = '/'
         paths.ui_value = path
 
-
         hgsettings1 = RhodeCodeSettings('realm', 'RhodeCode authentication')
         hgsettings2 = RhodeCodeSettings('title', 'RhodeCode')
 
-
         try:
             self.sa.add(web1)
             self.sa.add(web2)
@@ -427,8 +438,12 @@
                  ('hg.create.repository', 'Repository create'),
                  ('hg.create.none', 'Repository creation disabled'),
                  ('hg.register.none', 'Register disabled'),
-                 ('hg.register.manual_activate', 'Register new user with rhodecode without manual activation'),
-                 ('hg.register.auto_activate', 'Register new user with rhodecode without auto activation'),
+                 ('hg.register.manual_activate', ('Register new user with '
+                                                  'RhodeCode without '
+                                                  'manual activation')),
+                 ('hg.register.auto_activate', ('Register new user with '
+                                                'RhodeCode without auto '
+                                                'activation')),
                 ]
 
         for p in perms:
@@ -474,4 +489,3 @@
         except:
             self.sa.rollback()
             raise
-
--- a/rhodecode/model/scm.py	Tue Apr 05 17:34:04 2011 +0200
+++ b/rhodecode/model/scm.py	Tue Apr 05 18:01:19 2011 +0200
@@ -7,23 +7,21 @@
 
     :created_on: Apr 9, 2010
     :author: marcink
-    :copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>    
+    :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>
     :license: GPLv3, see COPYING for more details.
 """
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; version 2
-# of the License or (at your opinion) any later version of the license.
-# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA  02110-1301, USA.
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 import os
 import time
 import traceback
@@ -59,10 +57,19 @@
 class UserTemp(object):
     def __init__(self, user_id):
         self.user_id = user_id
+
+    def __repr__(self):
+        return "<%s('id:%s')>" % (self.__class__.__name__, self.user_id)
+
+
 class RepoTemp(object):
     def __init__(self, repo_id):
         self.repo_id = repo_id
 
+    def __repr__(self):
+        return "<%s('id:%s')>" % (self.__class__.__name__, self.repo_id)
+
+
 class ScmModel(BaseModel):
     """Generic Scm Model
     """
@@ -77,9 +84,9 @@
         return q.ui_value
 
     def repo_scan(self, repos_path, baseui):
-        """Listing of repositories in given path. This path should not be a 
+        """Listing of repositories in given path. This path should not be a
         repository itself. Return a dictionary of repository objects
-        
+
         :param repos_path: path to directory containing repositories
         :param baseui: baseui instance to instantiate MercurialRepostitory with
         """
@@ -92,7 +99,7 @@
 
         for name, path in get_repos(repos_path):
             try:
-                if repos_list.has_key(name):
+                if name in repos_list:
                     raise RepositoryError('Duplicate repository name %s '
                                     'found in %s' % (name, path))
                 else:
@@ -110,9 +117,9 @@
         return repos_list
 
     def get_repos(self, all_repos=None):
-        """Get all repos from db and for each repo create it's backend instance.
-        and fill that backed with information from database
-        
+        """Get all repos from db and for each repo create it's
+        backend instance.and fill that backed with information from database
+
         :param all_repos: give specific repositories list, good for filtering
         """
 
@@ -140,7 +147,8 @@
                 tmp_d['description'] = repo.dbrepo.description
                 tmp_d['description_sort'] = tmp_d['description']
                 tmp_d['last_change'] = last_change
-                tmp_d['last_change_sort'] = time.mktime(last_change.timetuple())
+                tmp_d['last_change_sort'] = time.mktime(last_change \
+                                                        .timetuple())
                 tmp_d['tip'] = tip.raw_id
                 tmp_d['tip_sort'] = tip.revision
                 tmp_d['rev'] = tip.revision
@@ -158,12 +166,12 @@
     def get(self, repo_name, invalidation_list=None):
         """Get's repository from given name, creates BackendInstance and
         propagates it's data from database with all additional information
-        
+
         :param repo_name:
         :param invalidation_list: if a invalidation list is given the get
-            method should not manually check if this repository needs 
+            method should not manually check if this repository needs
             invalidation and just invalidate the repositories in list
-            
+
         """
         if not HasRepoPermissionAny('repository.read', 'repository.write',
                             'repository.admin')(repo_name, 'get repo check'):
@@ -224,12 +232,10 @@
 
         return _get_repo(repo_name)
 
-
+    def mark_for_invalidation(self, repo_name):
+        """Puts cache invalidation task into db for
+        further global cache invalidation
 
-    def mark_for_invalidation(self, repo_name):
-        """Puts cache invalidation task into db for 
-        further global cache invalidation
-        
         :param repo_name: this repo that should invalidation take place
         """
 
@@ -251,7 +257,6 @@
             log.error(traceback.format_exc())
             self.sa.rollback()
 
-
     def toggle_following_repo(self, follow_repo_id, user_id):
 
         f = self.sa.query(UserFollowing)\
@@ -272,7 +277,6 @@
                 self.sa.rollback()
                 raise
 
-
         try:
             f = UserFollowing()
             f.user_id = user_id
@@ -287,7 +291,7 @@
             self.sa.rollback()
             raise
 
-    def toggle_following_user(self, follow_user_id , user_id):
+    def toggle_following_user(self, follow_user_id, user_id):
         f = self.sa.query(UserFollowing)\
             .filter(UserFollowing.follows_user_id == follow_user_id)\
             .filter(UserFollowing.user_id == user_id).scalar()
@@ -340,14 +344,12 @@
         return self.sa.query(Repository)\
                 .filter(Repository.fork_id == repo_id).count()
 
-
     def get_unread_journal(self):
         return self.sa.query(UserLog).count()
 
-
     def _should_invalidate(self, repo_name):
         """Looks up database for invalidation signals for this repo_name
-        
+
         :param repo_name:
         """
 
@@ -361,8 +363,9 @@
         return ret
 
     def _mark_invalidated(self, cache_key):
-        """ Marks all occurences of cache to invaldation as already invalidated
-        
+        """ Marks all occurences of cache to invaldation as
+        already invalidated
+
         :param cache_key:
         """
 
@@ -375,4 +378,3 @@
         except (DatabaseError,):
             log.error(traceback.format_exc())
             self.sa.rollback()
-
--- a/rhodecode/templates/base/base.html	Tue Apr 05 17:34:04 2011 +0200
+++ b/rhodecode/templates/base/base.html	Tue Apr 05 18:01:19 2011 +0200
@@ -85,7 +85,6 @@
 	   <div id="footer-inner" class="title bottom-left-rounded-corner bottom-right-rounded-corner">
 	       <div>
 	           <p class="footer-link">${h.link_to(_('Submit a bug'),h.url('bugtracker'))}</p>
-		       <p class="footer-link">${h.link_to(_('GPL license'),h.url('gpl_license'))}</p>
 		       <p class="footer-link-right"><a href="${h.url('rhodecode_official')}">RhodeCode</a> ${c.rhodecode_version} &copy; 2010-2011 by Marcin Kuzminski</p>
 	       </div>
 	   </div>