comparison rhodecode/controllers/api/api.py @ 1445:c78f6bf52e9c beta

Beginning of API implementation for rhodecode
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 20 Aug 2011 18:13:54 +0300
parents
children 256e729a94cd
comparison
equal deleted inserted replaced
1444:d17aa79768f0 1445:c78f6bf52e9c
1 from rhodecode.controllers.api import JSONRPCController, JSONRPCError
2 from rhodecode.lib.auth import HasPermissionAllDecorator
3 from rhodecode.model.scm import ScmModel
4
5
6 class ApiController(JSONRPCController):
7 """
8 API Controller
9
10
11 Each method needs to have USER as argument this is then based on given
12 API_KEY propagated as instance of user object
13
14 Preferably this should be first argument also
15
16
17 Each function should also **raise** JSONRPCError for any
18 errors that happens
19
20 """
21
22 @HasPermissionAllDecorator('hg.admin')
23 def pull(self, user, repo):
24 """
25 Dispatch pull action on given repo
26
27
28 param user:
29 param repo:
30 """
31
32 try:
33 ScmModel().pull_changes(repo, self.rhodecode_user.username)
34 return 'Pulled from %s' % repo
35 except Exception:
36 raise JSONRPCError('Unable to pull changes from "%s"' % repo)
37
38
39
40