##// END OF EJS Templates
Fixed bug in repos, added dependencies and bumped version
marcink -
r246:ca80f8c0 rhodecode-0.0.0.7.6 default
parent child Browse files
Show More
@@ -1,13 +1,13
1 """
1 """
2 Hg app, a web based mercurial repository managment based on pylons
2 Hg app, a web based mercurial repository managment based on pylons
3 """
3 """
4
4
5 VERSION = (0, 7, 5, 'beta')
5 VERSION = (0, 7, 6, 'beta')
6
6
7 __version__ = '.'.join((str(each) for each in VERSION[:4]))
7 __version__ = '.'.join((str(each) for each in VERSION[:4]))
8
8
9 def get_version():
9 def get_version():
10 """
10 """
11 Returns shorter version (digit parts only) as string.
11 Returns shorter version (digit parts only) as string.
12 """
12 """
13 return '.'.join((str(each) for each in VERSION[:3]))
13 return '.'.join((str(each) for each in VERSION[:3]))
@@ -1,97 +1,100
1 from pylons import request, response, session, tmpl_context as c, url, \
1 from pylons import request, response, session, tmpl_context as c, url, \
2 app_globals as g
2 app_globals as g
3 from pylons.controllers.util import abort, redirect
3 from pylons.controllers.util import abort, redirect
4 from pylons_app.lib.auth import LoginRequired
4 from pylons_app.lib.auth import LoginRequired
5 from pylons_app.lib.base import BaseController, render
5 from pylons_app.lib.base import BaseController, render
6 from pylons_app.lib.filters import clean_repo
6 from pylons_app.lib.filters import clean_repo
7 from pylons_app.lib.utils import check_repo, invalidate_cache
7 from pylons_app.lib.utils import check_repo, invalidate_cache
8 from pylons_app.model.hg_model import HgModel
8 import logging
9 import logging
9 import os
10 import os
10 import shutil
11 import shutil
12 from operator import itemgetter
11 log = logging.getLogger(__name__)
13 log = logging.getLogger(__name__)
12
14
13 class ReposController(BaseController):
15 class ReposController(BaseController):
14 """REST Controller styled on the Atom Publishing Protocol"""
16 """REST Controller styled on the Atom Publishing Protocol"""
15 # To properly map this controller, ensure your config/routing.py
17 # To properly map this controller, ensure your config/routing.py
16 # file has a resource setup:
18 # file has a resource setup:
17 # map.resource('repo', 'repos')
19 # map.resource('repo', 'repos')
18 @LoginRequired()
20 @LoginRequired()
19 def __before__(self):
21 def __before__(self):
20 c.admin_user = session.get('admin_user')
22 c.admin_user = session.get('admin_user')
21 c.admin_username = session.get('admin_username')
23 c.admin_username = session.get('admin_username')
22 super(ReposController, self).__before__()
24 super(ReposController, self).__before__()
23
25
24 def index(self, format='html'):
26 def index(self, format='html'):
25 """GET /repos: All items in the collection"""
27 """GET /repos: All items in the collection"""
26 # url('repos')
28 # url('repos')
27 c.repos_list = c.cached_repo_list
29 cached_repo_list = HgModel().get_repos()
30 c.repos_list = sorted(cached_repo_list, key=itemgetter('name'))
28 return render('admin/repos/repos.html')
31 return render('admin/repos/repos.html')
29
32
30 def create(self):
33 def create(self):
31 """POST /repos: Create a new item"""
34 """POST /repos: Create a new item"""
32 # url('repos')
35 # url('repos')
33 name = request.POST.get('name')
36 name = request.POST.get('name')
34
37
35 try:
38 try:
36 self._create_repo(name)
39 self._create_repo(name)
37 #clear our cached list for refresh with new repo
40 #clear our cached list for refresh with new repo
38 invalidate_cache('cached_repo_list')
41 invalidate_cache('cached_repo_list')
39 except Exception as e:
42 except Exception as e:
40 log.error(e)
43 log.error(e)
41
44
42 return redirect('repos')
45 return redirect('repos')
43
46
44 def _create_repo(self, repo_name):
47 def _create_repo(self, repo_name):
45 repo_path = os.path.join(g.base_path, repo_name)
48 repo_path = os.path.join(g.base_path, repo_name)
46 if check_repo(repo_name, g.base_path):
49 if check_repo(repo_name, g.base_path):
47 log.info('creating repo %s in %s', repo_name, repo_path)
50 log.info('creating repo %s in %s', repo_name, repo_path)
48 from vcs.backends.hg import MercurialRepository
51 from vcs.backends.hg import MercurialRepository
49 MercurialRepository(repo_path, create=True)
52 MercurialRepository(repo_path, create=True)
50
53
51
54
52 def new(self, format='html'):
55 def new(self, format='html'):
53 """GET /repos/new: Form to create a new item"""
56 """GET /repos/new: Form to create a new item"""
54 new_repo = request.GET.get('repo', '')
57 new_repo = request.GET.get('repo', '')
55 c.new_repo = clean_repo(new_repo)
58 c.new_repo = clean_repo(new_repo)
56
59
57 return render('admin/repos/repo_add.html')
60 return render('admin/repos/repo_add.html')
58
61
59 def update(self, id):
62 def update(self, id):
60 """PUT /repos/id: Update an existing item"""
63 """PUT /repos/id: Update an existing item"""
61 # Forms posted to this method should contain a hidden field:
64 # Forms posted to this method should contain a hidden field:
62 # <input type="hidden" name="_method" value="PUT" />
65 # <input type="hidden" name="_method" value="PUT" />
63 # Or using helpers:
66 # Or using helpers:
64 # h.form(url('repo', id=ID),
67 # h.form(url('repo', id=ID),
65 # method='put')
68 # method='put')
66 # url('repo', id=ID)
69 # url('repo', id=ID)
67
70
68 def delete(self, id):
71 def delete(self, id):
69 """DELETE /repos/id: Delete an existing item"""
72 """DELETE /repos/id: Delete an existing item"""
70 # Forms posted to this method should contain a hidden field:
73 # Forms posted to this method should contain a hidden field:
71 # <input type="hidden" name="_method" value="DELETE" />
74 # <input type="hidden" name="_method" value="DELETE" />
72 # Or using helpers:
75 # Or using helpers:
73 # h.form(url('repo', id=ID),
76 # h.form(url('repo', id=ID),
74 # method='delete')
77 # method='delete')
75 # url('repo', id=ID)
78 # url('repo', id=ID)
76 from datetime import datetime
79 from datetime import datetime
77 path = g.paths[0][1].replace('*', '')
80 path = g.paths[0][1].replace('*', '')
78 rm_path = os.path.join(path, id)
81 rm_path = os.path.join(path, id)
79 log.info("Removing %s", rm_path)
82 log.info("Removing %s", rm_path)
80 shutil.move(os.path.join(rm_path, '.hg'), os.path.join(rm_path, 'rm__.hg'))
83 shutil.move(os.path.join(rm_path, '.hg'), os.path.join(rm_path, 'rm__.hg'))
81 shutil.move(rm_path, os.path.join(path, 'rm__%s-%s' % (datetime.today(), id)))
84 shutil.move(rm_path, os.path.join(path, 'rm__%s-%s' % (datetime.today(), id)))
82
85
83 #clear our cached list for refresh with new repo
86 #clear our cached list for refresh with new repo
84 invalidate_cache('cached_repo_list')
87 invalidate_cache('cached_repo_list')
85
88
86 return redirect(url('repos'))
89 return redirect(url('repos'))
87
90
88
91
89 def show(self, id, format='html'):
92 def show(self, id, format='html'):
90 """GET /repos/id: Show a specific item"""
93 """GET /repos/id: Show a specific item"""
91 # url('repo', id=ID)
94 # url('repo', id=ID)
92
95
93 def edit(self, id, format='html'):
96 def edit(self, id, format='html'):
94 """GET /repos/id/edit: Form to edit an existing item"""
97 """GET /repos/id/edit: Form to edit an existing item"""
95 # url('edit_repo', id=ID)
98 # url('edit_repo', id=ID)
96 c.new_repo = id
99 c.new_repo = id
97 return render('admin/repos/repo_edit.html')
100 return render('admin/repos/repo_edit.html')
@@ -1,41 +1,43
1 from pylons_app import get_version
1 from pylons_app import get_version
2 try:
2 try:
3 from setuptools import setup, find_packages
3 from setuptools import setup, find_packages
4 except ImportError:
4 except ImportError:
5 from ez_setup import use_setuptools
5 from ez_setup import use_setuptools
6 use_setuptools()
6 use_setuptools()
7 from setuptools import setup, find_packages
7 from setuptools import setup, find_packages
8
8
9 setup(
9 setup(
10 name='pylons_app',
10 name='pylons_app',
11 version=get_version(),
11 version=get_version(),
12 description='',
12 description='',
13 author='marcin kuzminski',
13 author='marcin kuzminski',
14 author_email='marcin@python-works.com',
14 author_email='marcin@python-works.com',
15 url='',
15 url='',
16 install_requires=[
16 install_requires=[
17 "Pylons>=1.0.0",
17 "Pylons>=1.0.0",
18 "SQLAlchemy>=0.6",
18 "SQLAlchemy>=0.6",
19 "Mako>=0.3.2",
19 "Mako>=0.3.2",
20 "vcs>=0.1.2",
20 "vcs>=0.1.2",
21 "pygments>=1.3.0"
21 "pygments>=1.3.0",
22 "mercurial>=1.5",
23 "pysqlite"
22 ],
24 ],
23 setup_requires=["PasteScript>=1.6.3"],
25 setup_requires=["PasteScript>=1.6.3"],
24 packages=find_packages(exclude=['ez_setup']),
26 packages=find_packages(exclude=['ez_setup']),
25 include_package_data=True,
27 include_package_data=True,
26 test_suite='nose.collector',
28 test_suite='nose.collector',
27 package_data={'pylons_app': ['i18n/*/LC_MESSAGES/*.mo']},
29 package_data={'pylons_app': ['i18n/*/LC_MESSAGES/*.mo']},
28 message_extractors={'pylons_app': [
30 message_extractors={'pylons_app': [
29 ('**.py', 'python', None),
31 ('**.py', 'python', None),
30 ('templates/**.mako', 'mako', {'input_encoding': 'utf-8'}),
32 ('templates/**.mako', 'mako', {'input_encoding': 'utf-8'}),
31 ('public/**', 'ignore', None)]},
33 ('public/**', 'ignore', None)]},
32 zip_safe=False,
34 zip_safe=False,
33 paster_plugins=['PasteScript', 'Pylons'],
35 paster_plugins=['PasteScript', 'Pylons'],
34 entry_points="""
36 entry_points="""
35 [paste.app_factory]
37 [paste.app_factory]
36 main = pylons_app.config.middleware:make_app
38 main = pylons_app.config.middleware:make_app
37
39
38 [paste.app_install]
40 [paste.app_install]
39 main = pylons.util:PylonsInstaller
41 main = pylons.util:PylonsInstaller
40 """,
42 """,
41 )
43 )
General Comments 0
You need to be logged in to leave comments. Login now