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