Mercurial > public > src > rhodecode
comparison pylons_app/controllers/users.py @ 47:f6ac79182600
Added rest controllers for repos and users,
templating changes + css fixes
author | Marcin Kuzminski <marcin@python-blog.com> |
---|---|
date | Wed, 07 Apr 2010 20:19:25 +0200 |
parents | |
children | 8e250e86a670 |
comparison
equal
deleted
inserted
replaced
46:9db7782727b3 | 47:f6ac79182600 |
---|---|
1 import logging | |
2 | |
3 from pylons import request, response, session, tmpl_context as c, url, app_globals as g | |
4 from pylons.controllers.util import abort, redirect | |
5 | |
6 from pylons_app.lib.base import BaseController, render | |
7 from pylons_app.lib import auth | |
8 log = logging.getLogger(__name__) | |
9 | |
10 class UsersController(BaseController): | |
11 """REST Controller styled on the Atom Publishing Protocol""" | |
12 # To properly map this controller, ensure your config/routing.py | |
13 # file has a resource setup: | |
14 # map.resource('user', 'users') | |
15 def __before__(self): | |
16 c.staticurl = g.statics | |
17 c.admin_user = session.get('admin_user') | |
18 c.admin_username = session.get('admin_username') | |
19 | |
20 def index(self, format='html'): | |
21 """GET /users: All items in the collection""" | |
22 # url('users') | |
23 conn, cur = auth.get_sqlite_conn_cur() | |
24 cur.execute('SELECT * FROM users') | |
25 c.users_list = cur.fetchall() | |
26 return render('/users_manage.html') | |
27 | |
28 def create(self): | |
29 """POST /users: Create a new item""" | |
30 # url('users') | |
31 | |
32 def new(self, format='html'): | |
33 """GET /users/new: Form to create a new item""" | |
34 # url('new_user') | |
35 | |
36 def update(self, id): | |
37 """PUT /users/id: Update an existing item""" | |
38 # Forms posted to this method should contain a hidden field: | |
39 # <input type="hidden" name="_method" value="PUT" /> | |
40 # Or using helpers: | |
41 # h.form(url('user', id=ID), | |
42 # method='put') | |
43 # url('user', id=ID) | |
44 | |
45 def delete(self, id): | |
46 """DELETE /users/id: Delete an existing item""" | |
47 # Forms posted to this method should contain a hidden field: | |
48 # <input type="hidden" name="_method" value="DELETE" /> | |
49 # Or using helpers: | |
50 # h.form(url('user', id=ID), | |
51 # method='delete') | |
52 # url('user', id=ID) | |
53 | |
54 def show(self, id, format='html'): | |
55 """GET /users/id: Show a specific item""" | |
56 # url('user', id=ID) | |
57 | |
58 def edit(self, id, format='html'): | |
59 """GET /users/id/edit: Form to edit an existing item""" | |
60 # url('edit_user', id=ID) |