comparison pylons_app/controllers/repos.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 from pylons_app.lib import auth
6 from pylons_app.lib.base import BaseController, render
7
8 log = logging.getLogger(__name__)
9
10 class ReposController(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('repo', 'repos')
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 /repos: All items in the collection"""
22 # url('repos')
23 return render('/repos_manage.html')
24
25 def create(self):
26 """POST /repos: Create a new item"""
27 # url('repos')
28
29 def new(self, format='html'):
30 """GET /repos/new: Form to create a new item"""
31 # url('new_repo')
32
33 def update(self, id):
34 """PUT /repos/id: Update an existing item"""
35 # Forms posted to this method should contain a hidden field:
36 # <input type="hidden" name="_method" value="PUT" />
37 # Or using helpers:
38 # h.form(url('repo', id=ID),
39 # method='put')
40 # url('repo', id=ID)
41
42 def delete(self, id):
43 """DELETE /repos/id: Delete an existing item"""
44 # Forms posted to this method should contain a hidden field:
45 # <input type="hidden" name="_method" value="DELETE" />
46 # Or using helpers:
47 # h.form(url('repo', id=ID),
48 # method='delete')
49 # url('repo', id=ID)
50
51 def show(self, id, format='html'):
52 """GET /repos/id: Show a specific item"""
53 # url('repo', id=ID)
54
55 def edit(self, id, format='html'):
56 """GET /repos/id/edit: Form to edit an existing item"""
57 # url('edit_repo', id=ID)