annotate kallithea/controllers/api/__init__.py @ 8809:4f0de9468da3

controllers: move controllers base class from lib/base to controllers TG quickstart put it in lib/base.py , but it fits better on the controllers layer as a base there. The contributing docs were a bit ahead of time ... but with a typo.
author Mads Kiilerich <mads@kiilerich.com>
date Fri, 13 Nov 2020 01:06:16 +0100
parents b3d8a3000a7f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3179
diff changeset
2 # This program is free software: you can redistribute it and/or modify
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3179
diff changeset
3 # it under the terms of the GNU General Public License as published by
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3179
diff changeset
4 # the Free Software Foundation, either version 3 of the License, or
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3179
diff changeset
5 # (at your option) any later version.
1818
cf51bbfb120e auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents: 1796
diff changeset
6 #
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7 # This program is distributed in the hope that it will be useful,
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10 # GNU General Public License for more details.
1818
cf51bbfb120e auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents: 1796
diff changeset
11 #
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12 # You should have received a copy of the GNU General Public License
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3179
diff changeset
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3179
diff changeset
14 """
4186
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
15 kallithea.controllers.api
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3179
diff changeset
16 ~~~~~~~~~~~~~~~~~~~~~~~~~
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3179
diff changeset
17
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3179
diff changeset
18 JSON RPC controller
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3179
diff changeset
19
4211
1948ede028ef RhodeCode GmbH is not the sole author of this work
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4208
diff changeset
20 This file was forked by the Kallithea project in July 2014.
1948ede028ef RhodeCode GmbH is not the sole author of this work
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4208
diff changeset
21 Original author and date, and relevant copyright and licensing information is below:
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3179
diff changeset
22 :created_on: Aug 20, 2011
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3179
diff changeset
23 :author: marcink
4211
1948ede028ef RhodeCode GmbH is not the sole author of this work
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4208
diff changeset
24 :copyright: (c) 2013 RhodeCode GmbH, and others.
4208
ad38f9f93b3b Correct licensing information in individual files.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4197
diff changeset
25 :license: GPLv3, see LICENSE.md for more details.
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3179
diff changeset
26 """
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
27
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
28 import inspect
7811
0a277465fddf scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents: 7697
diff changeset
29 import itertools
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
30 import logging
2656
c785ad556d44 added extra logging into API calls
Marcin Kuzminski <marcin@python-works.com>
parents: 2379
diff changeset
31 import time
7811
0a277465fddf scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents: 7697
diff changeset
32 import traceback
0a277465fddf scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents: 7697
diff changeset
33 import types
1514
87ec80c280bb fixed issues with python2.5
Marcin Kuzminski <marcin@python-works.com>
parents: 1508
diff changeset
34
7811
0a277465fddf scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents: 7697
diff changeset
35 from tg import Response, TGController, request, response
7812
fe4086096758 flake8: fix some F401 '...' imported but unused
Mads Kiilerich <mads@kiilerich.com>
parents: 7811
diff changeset
36 from webob.exc import HTTPError, HTTPException
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
37
8809
4f0de9468da3 controllers: move controllers base class from lib/base to controllers
Mads Kiilerich <mads@kiilerich.com>
parents: 8791
diff changeset
38 from kallithea.controllers import base
8120
58b6e4cd6fe9 lib: clean up ext_json and how it is used - avoid monkey patching
Mads Kiilerich <mads@kiilerich.com>
parents: 8074
diff changeset
39 from kallithea.lib import ext_json
7811
0a277465fddf scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents: 7697
diff changeset
40 from kallithea.lib.auth import AuthUser
8196
e51ad2cd400e py3: drop the last uses of safe_str - they are no longer relevant when we don't have a separate unicode type
Mads Kiilerich <mads@kiilerich.com>
parents: 8192
diff changeset
41 from kallithea.lib.utils2 import ascii_bytes
8687
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8201
diff changeset
42 from kallithea.model import db
7811
0a277465fddf scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents: 7697
diff changeset
43
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
44
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
45 log = logging.getLogger('JSONRPC')
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
46
1793
631caf880b87 implements #329
Marcin Kuzminski <marcin@python-works.com>
parents: 1708
diff changeset
47
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
48 class JSONRPCError(BaseException):
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50 def __init__(self, message):
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51 self.message = message
1708
fee9895fa46e changed API to match fully JSON-RPC specs
Marcin Kuzminski <marcin@python-works.com>
parents: 1693
diff changeset
52 super(JSONRPCError, self).__init__()
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
53
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
54 def __str__(self):
8196
e51ad2cd400e py3: drop the last uses of safe_str - they are no longer relevant when we don't have a separate unicode type
Mads Kiilerich <mads@kiilerich.com>
parents: 8192
diff changeset
55 return self.message
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
56
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
57
6569
e1ab82613133 backend: replace Pylons with TurboGears2
Alessandro Molina <alessandro.molina@axant.it>
parents: 6553
diff changeset
58 class JSONRPCErrorResponse(Response, HTTPException):
1661
fe5575f95850 API returns proper JSON response
Marcin Kuzminski <marcin@python-works.com>
parents: 1514
diff changeset
59 """
fe5575f95850 API returns proper JSON response
Marcin Kuzminski <marcin@python-works.com>
parents: 1514
diff changeset
60 Generate a Response object with a JSON-RPC error body
6376
dc94e662ee74 tg: refactor API JSON RPC error handling to prepare for TG
Mads Kiilerich <mads@kiilerich.com>
parents: 6212
diff changeset
61 """
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3179
diff changeset
62
6376
dc94e662ee74 tg: refactor API JSON RPC error handling to prepare for TG
Mads Kiilerich <mads@kiilerich.com>
parents: 6212
diff changeset
63 def __init__(self, message=None, retid=None, code=None):
6569
e1ab82613133 backend: replace Pylons with TurboGears2
Alessandro Molina <alessandro.molina@axant.it>
parents: 6553
diff changeset
64 HTTPException.__init__(self, message, self)
6376
dc94e662ee74 tg: refactor API JSON RPC error handling to prepare for TG
Mads Kiilerich <mads@kiilerich.com>
parents: 6212
diff changeset
65 Response.__init__(self,
6569
e1ab82613133 backend: replace Pylons with TurboGears2
Alessandro Molina <alessandro.molina@axant.it>
parents: 6553
diff changeset
66 json_body=dict(id=retid, result=None, error=message),
6376
dc94e662ee74 tg: refactor API JSON RPC error handling to prepare for TG
Mads Kiilerich <mads@kiilerich.com>
parents: 6212
diff changeset
67 status=code,
dc94e662ee74 tg: refactor API JSON RPC error handling to prepare for TG
Mads Kiilerich <mads@kiilerich.com>
parents: 6212
diff changeset
68 content_type='application/json')
1661
fe5575f95850 API returns proper JSON response
Marcin Kuzminski <marcin@python-works.com>
parents: 1514
diff changeset
69
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
70
6569
e1ab82613133 backend: replace Pylons with TurboGears2
Alessandro Molina <alessandro.molina@axant.it>
parents: 6553
diff changeset
71 class JSONRPCController(TGController):
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
72 """
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
73 A WSGI-speaking JSON-RPC controller class
1793
631caf880b87 implements #329
Marcin Kuzminski <marcin@python-works.com>
parents: 1708
diff changeset
74
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
75 See the specification:
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
76 <http://json-rpc.org/wiki/specification>`.
1793
631caf880b87 implements #329
Marcin Kuzminski <marcin@python-works.com>
parents: 1708
diff changeset
77
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
78 Valid controller return values should be json-serializable objects.
1793
631caf880b87 implements #329
Marcin Kuzminski <marcin@python-works.com>
parents: 1708
diff changeset
79
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
80 Sub-classes should catch their exceptions and raise JSONRPCError
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
81 if they want to pass meaningful errors to the client.
1793
631caf880b87 implements #329
Marcin Kuzminski <marcin@python-works.com>
parents: 1708
diff changeset
82
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
83 """
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
84
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
85 def _get_method_args(self):
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
86 """
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
87 Return `self._rpc_args` to dispatched controller method
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
88 chosen by __call__
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
89 """
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
90 return self._rpc_args
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
91
6569
e1ab82613133 backend: replace Pylons with TurboGears2
Alessandro Molina <alessandro.molina@axant.it>
parents: 6553
diff changeset
92 def _dispatch(self, state, remainder=None):
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
93 """
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
94 Parse the request body as JSON, look up the method on the
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
95 controller and if it exists, dispatch to it.
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
96 """
6569
e1ab82613133 backend: replace Pylons with TurboGears2
Alessandro Molina <alessandro.molina@axant.it>
parents: 6553
diff changeset
97 # Since we are here we should respond as JSON
e1ab82613133 backend: replace Pylons with TurboGears2
Alessandro Molina <alessandro.molina@axant.it>
parents: 6553
diff changeset
98 response.content_type = 'application/json'
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3179
diff changeset
99
6569
e1ab82613133 backend: replace Pylons with TurboGears2
Alessandro Molina <alessandro.molina@axant.it>
parents: 6553
diff changeset
100 environ = state.request.environ
2656
c785ad556d44 added extra logging into API calls
Marcin Kuzminski <marcin@python-works.com>
parents: 2379
diff changeset
101 start = time.time()
8809
4f0de9468da3 controllers: move controllers base class from lib/base to controllers
Mads Kiilerich <mads@kiilerich.com>
parents: 8791
diff changeset
102 ip_addr = base.get_ip_addr(environ)
2379
7ac09514a178 created rhodecode-api binary script for working with api via cli
Marcin Kuzminski <marcin@python-works.com>
parents: 2151
diff changeset
103 self._req_id = None
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
104 if 'CONTENT_LENGTH' not in environ:
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
105 log.debug("No Content-Length")
6376
dc94e662ee74 tg: refactor API JSON RPC error handling to prepare for TG
Mads Kiilerich <mads@kiilerich.com>
parents: 6212
diff changeset
106 raise JSONRPCErrorResponse(retid=self._req_id,
dc94e662ee74 tg: refactor API JSON RPC error handling to prepare for TG
Mads Kiilerich <mads@kiilerich.com>
parents: 6212
diff changeset
107 message="No Content-Length in request")
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
108 else:
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
109 length = environ['CONTENT_LENGTH'] or 0
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
110 length = int(environ['CONTENT_LENGTH'])
5375
0210d0b769d4 cleanup: pass log strings unformatted - avoid unnecessary % formatting when not logging
Mads Kiilerich <madski@unity3d.com>
parents: 5374
diff changeset
111 log.debug('Content-Length: %s', length)
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
112
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
113 if length == 0:
6376
dc94e662ee74 tg: refactor API JSON RPC error handling to prepare for TG
Mads Kiilerich <mads@kiilerich.com>
parents: 6212
diff changeset
114 raise JSONRPCErrorResponse(retid=self._req_id,
dc94e662ee74 tg: refactor API JSON RPC error handling to prepare for TG
Mads Kiilerich <mads@kiilerich.com>
parents: 6212
diff changeset
115 message="Content-Length is 0")
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
116
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
117 raw_body = environ['wsgi.input'].read(length)
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
118
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
119 try:
8120
58b6e4cd6fe9 lib: clean up ext_json and how it is used - avoid monkey patching
Mads Kiilerich <mads@kiilerich.com>
parents: 8074
diff changeset
120 json_body = ext_json.loads(raw_body)
5374
d69aa464f373 cleanup: consistently use 'except ... as ...:'
Mads Kiilerich <madski@unity3d.com>
parents: 5326
diff changeset
121 except ValueError as e:
1793
631caf880b87 implements #329
Marcin Kuzminski <marcin@python-works.com>
parents: 1708
diff changeset
122 # catch JSON errors Here
6376
dc94e662ee74 tg: refactor API JSON RPC error handling to prepare for TG
Mads Kiilerich <mads@kiilerich.com>
parents: 6212
diff changeset
123 raise JSONRPCErrorResponse(retid=self._req_id,
dc94e662ee74 tg: refactor API JSON RPC error handling to prepare for TG
Mads Kiilerich <mads@kiilerich.com>
parents: 6212
diff changeset
124 message="JSON parse error ERR:%s RAW:%r"
dc94e662ee74 tg: refactor API JSON RPC error handling to prepare for TG
Mads Kiilerich <mads@kiilerich.com>
parents: 6212
diff changeset
125 % (e, raw_body))
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
126
5124
e3aab61a9411 spelling: more consistent casing of 'API key'
Mads Kiilerich <madski@unity3d.com>
parents: 4422
diff changeset
127 # check AUTH based on API key
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
128 try:
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
129 self._req_api_key = json_body['api_key']
1708
fee9895fa46e changed API to match fully JSON-RPC specs
Marcin Kuzminski <marcin@python-works.com>
parents: 1693
diff changeset
130 self._req_id = json_body['id']
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
131 self._req_method = json_body['method']
1793
631caf880b87 implements #329
Marcin Kuzminski <marcin@python-works.com>
parents: 1708
diff changeset
132 self._request_params = json_body['args']
3165
e1baadec6217 fixes issue #702 API methods without arguments fail when "args":null
Marcin Kuzminski <marcin@python-works.com>
parents: 3163
diff changeset
133 if not isinstance(self._request_params, dict):
e1baadec6217 fixes issue #702 API methods without arguments fail when "args":null
Marcin Kuzminski <marcin@python-works.com>
parents: 3163
diff changeset
134 self._request_params = {}
e1baadec6217 fixes issue #702 API methods without arguments fail when "args":null
Marcin Kuzminski <marcin@python-works.com>
parents: 3163
diff changeset
135
6376
dc94e662ee74 tg: refactor API JSON RPC error handling to prepare for TG
Mads Kiilerich <mads@kiilerich.com>
parents: 6212
diff changeset
136 log.debug('method: %s, params: %s',
dc94e662ee74 tg: refactor API JSON RPC error handling to prepare for TG
Mads Kiilerich <mads@kiilerich.com>
parents: 6212
diff changeset
137 self._req_method, self._request_params)
5374
d69aa464f373 cleanup: consistently use 'except ... as ...:'
Mads Kiilerich <madski@unity3d.com>
parents: 5326
diff changeset
138 except KeyError as e:
6376
dc94e662ee74 tg: refactor API JSON RPC error handling to prepare for TG
Mads Kiilerich <mads@kiilerich.com>
parents: 6212
diff changeset
139 raise JSONRPCErrorResponse(retid=self._req_id,
dc94e662ee74 tg: refactor API JSON RPC error handling to prepare for TG
Mads Kiilerich <mads@kiilerich.com>
parents: 6212
diff changeset
140 message='Incorrect JSON query missing %s' % e)
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
141
1693
60249224be04 fix for api key lookup, reuse same function in user model
Marcin Kuzminski <marcin@python-works.com>
parents: 1661
diff changeset
142 # check if we can find this session using api_key
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
143 try:
8687
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8201
diff changeset
144 u = db.User.get_by_api_key(self._req_api_key)
7697
226893a56a81 auth: move IP check to AuthUser.make - it is more about accepting authentication than about permissions after authentication
Mads Kiilerich <mads@kiilerich.com>
parents: 7696
diff changeset
145 auth_user = AuthUser.make(dbuser=u, ip_addr=ip_addr)
7696
077ba994ee03 auth: introduce AuthUser.make factory which can return None if user can't be authenticated
Mads Kiilerich <mads@kiilerich.com>
parents: 7485
diff changeset
146 if auth_user is None:
6376
dc94e662ee74 tg: refactor API JSON RPC error handling to prepare for TG
Mads Kiilerich <mads@kiilerich.com>
parents: 6212
diff changeset
147 raise JSONRPCErrorResponse(retid=self._req_id,
dc94e662ee74 tg: refactor API JSON RPC error handling to prepare for TG
Mads Kiilerich <mads@kiilerich.com>
parents: 6212
diff changeset
148 message='Invalid API key')
5374
d69aa464f373 cleanup: consistently use 'except ... as ...:'
Mads Kiilerich <madski@unity3d.com>
parents: 5326
diff changeset
149 except Exception as e:
6376
dc94e662ee74 tg: refactor API JSON RPC error handling to prepare for TG
Mads Kiilerich <mads@kiilerich.com>
parents: 6212
diff changeset
150 raise JSONRPCErrorResponse(retid=self._req_id,
dc94e662ee74 tg: refactor API JSON RPC error handling to prepare for TG
Mads Kiilerich <mads@kiilerich.com>
parents: 6212
diff changeset
151 message='Invalid API key')
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
152
7696
077ba994ee03 auth: introduce AuthUser.make factory which can return None if user can't be authenticated
Mads Kiilerich <mads@kiilerich.com>
parents: 7485
diff changeset
153 request.authuser = auth_user
7697
226893a56a81 auth: move IP check to AuthUser.make - it is more about accepting authentication than about permissions after authentication
Mads Kiilerich <mads@kiilerich.com>
parents: 7696
diff changeset
154 request.ip_addr = ip_addr
7696
077ba994ee03 auth: introduce AuthUser.make factory which can return None if user can't be authenticated
Mads Kiilerich <mads@kiilerich.com>
parents: 7485
diff changeset
155
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
156 self._error = None
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
157 try:
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
158 self._func = self._find_method()
5374
d69aa464f373 cleanup: consistently use 'except ... as ...:'
Mads Kiilerich <madski@unity3d.com>
parents: 5326
diff changeset
159 except AttributeError as e:
6376
dc94e662ee74 tg: refactor API JSON RPC error handling to prepare for TG
Mads Kiilerich <mads@kiilerich.com>
parents: 6212
diff changeset
160 raise JSONRPCErrorResponse(retid=self._req_id,
dc94e662ee74 tg: refactor API JSON RPC error handling to prepare for TG
Mads Kiilerich <mads@kiilerich.com>
parents: 6212
diff changeset
161 message=str(e))
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
162
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
163 # now that we have a method, add self._req_params to
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
164 # self.kargs and dispatch control to WGIController
8192
b7caa806cf6e py3: use inspect.getfullargspec instead of deprecated inspect.getargspec
Mads Kiilerich <mads@kiilerich.com>
parents: 8182
diff changeset
165 argspec = inspect.getfullargspec(self._func)
b7caa806cf6e py3: use inspect.getfullargspec instead of deprecated inspect.getargspec
Mads Kiilerich <mads@kiilerich.com>
parents: 8182
diff changeset
166 arglist = argspec.args[1:]
b7caa806cf6e py3: use inspect.getfullargspec instead of deprecated inspect.getargspec
Mads Kiilerich <mads@kiilerich.com>
parents: 8182
diff changeset
167 argtypes = [type(arg) for arg in argspec.defaults or []]
8011
4fcf63512b77 py3: prepare for types.NotImplementedType going away
Mads Kiilerich <mads@kiilerich.com>
parents: 7824
diff changeset
168 default_empty = type(NotImplemented)
1514
87ec80c280bb fixed issues with python2.5
Marcin Kuzminski <marcin@python-works.com>
parents: 1508
diff changeset
169
1793
631caf880b87 implements #329
Marcin Kuzminski <marcin@python-works.com>
parents: 1708
diff changeset
170 # kw arguments required by this method
8192
b7caa806cf6e py3: use inspect.getfullargspec instead of deprecated inspect.getargspec
Mads Kiilerich <mads@kiilerich.com>
parents: 8182
diff changeset
171 func_kwargs = dict(itertools.zip_longest(reversed(arglist), reversed(argtypes),
6208
f4d128af1a01 compat: drop unnecessary wrappers for old Python versions
Mads Kiilerich <madski@unity3d.com>
parents: 5790
diff changeset
172 fillvalue=default_empty))
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
173
1500
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1489
diff changeset
174 # This attribute will need to be first param of a method that uses
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1489
diff changeset
175 # api_key, which is translated to instance of user at that name
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1489
diff changeset
176 USER_SESSION_ATTR = 'apiuser'
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1489
diff changeset
177
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
178 # get our arglist and check if we provided them as args
8179
756e46bd926b py3: trivial renaming of .iteritems() to .items()
Mads Kiilerich <mads@kiilerich.com>
parents: 8120
diff changeset
179 for arg, default in func_kwargs.items():
1500
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1489
diff changeset
180 if arg == USER_SESSION_ATTR:
5124
e3aab61a9411 spelling: more consistent casing of 'API key'
Mads Kiilerich <madski@unity3d.com>
parents: 4422
diff changeset
181 # USER_SESSION_ATTR is something translated from API key and
1500
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1489
diff changeset
182 # this is checked before so we don't need validate it
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
183 continue
1514
87ec80c280bb fixed issues with python2.5
Marcin Kuzminski <marcin@python-works.com>
parents: 1508
diff changeset
184
1793
631caf880b87 implements #329
Marcin Kuzminski <marcin@python-works.com>
parents: 1708
diff changeset
185 # skip the required param check if it's default value is
1504
ed3254ac279b Added optional arguments into API
Marcin Kuzminski <marcin@python-works.com>
parents: 1500
diff changeset
186 # NotImplementedType (default_empty)
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3179
diff changeset
187 if default == default_empty and arg not in self._request_params:
6376
dc94e662ee74 tg: refactor API JSON RPC error handling to prepare for TG
Mads Kiilerich <mads@kiilerich.com>
parents: 6212
diff changeset
188 raise JSONRPCErrorResponse(
2379
7ac09514a178 created rhodecode-api binary script for working with api via cli
Marcin Kuzminski <marcin@python-works.com>
parents: 2151
diff changeset
189 retid=self._req_id,
6376
dc94e662ee74 tg: refactor API JSON RPC error handling to prepare for TG
Mads Kiilerich <mads@kiilerich.com>
parents: 6212
diff changeset
190 message='Missing non optional `%s` arg in JSON DATA' % arg,
1793
631caf880b87 implements #329
Marcin Kuzminski <marcin@python-works.com>
parents: 1708
diff changeset
191 )
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
192
6212
8be0633ff852 api: fail when given unknown arguments
Mads Kiilerich <madski@unity3d.com>
parents: 6211
diff changeset
193 extra = set(self._request_params).difference(func_kwargs)
8be0633ff852 api: fail when given unknown arguments
Mads Kiilerich <madski@unity3d.com>
parents: 6211
diff changeset
194 if extra:
7824
548357c4301d flake8: fix E117 over-indented
Mads Kiilerich <mads@kiilerich.com>
parents: 7812
diff changeset
195 raise JSONRPCErrorResponse(
548357c4301d flake8: fix E117 over-indented
Mads Kiilerich <mads@kiilerich.com>
parents: 7812
diff changeset
196 retid=self._req_id,
548357c4301d flake8: fix E117 over-indented
Mads Kiilerich <mads@kiilerich.com>
parents: 7812
diff changeset
197 message='Unknown %s arg in JSON DATA' %
548357c4301d flake8: fix E117 over-indented
Mads Kiilerich <mads@kiilerich.com>
parents: 7812
diff changeset
198 ', '.join('`%s`' % arg for arg in extra),
548357c4301d flake8: fix E117 over-indented
Mads Kiilerich <mads@kiilerich.com>
parents: 7812
diff changeset
199 )
6212
8be0633ff852 api: fail when given unknown arguments
Mads Kiilerich <madski@unity3d.com>
parents: 6211
diff changeset
200
6211
2990b0587e3f api: stop passing apiuser as parameter to handler functions - if they really need it, use self.authuser
Mads Kiilerich <madski@unity3d.com>
parents: 6209
diff changeset
201 self._rpc_args = {}
1793
631caf880b87 implements #329
Marcin Kuzminski <marcin@python-works.com>
parents: 1708
diff changeset
202 self._rpc_args.update(self._request_params)
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
203 self._rpc_args['action'] = self._req_method
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
204 self._rpc_args['environ'] = environ
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
205
2656
c785ad556d44 added extra logging into API calls
Marcin Kuzminski <marcin@python-works.com>
parents: 2379
diff changeset
206 log.info('IP: %s Request to %s time: %.3fs' % (
8809
4f0de9468da3 controllers: move controllers base class from lib/base to controllers
Mads Kiilerich <mads@kiilerich.com>
parents: 8791
diff changeset
207 base.get_ip_addr(environ),
4f0de9468da3 controllers: move controllers base class from lib/base to controllers
Mads Kiilerich <mads@kiilerich.com>
parents: 8791
diff changeset
208 base.get_path_info(environ), time.time() - start)
2656
c785ad556d44 added extra logging into API calls
Marcin Kuzminski <marcin@python-works.com>
parents: 2379
diff changeset
209 )
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
210
6569
e1ab82613133 backend: replace Pylons with TurboGears2
Alessandro Molina <alessandro.molina@axant.it>
parents: 6553
diff changeset
211 state.set_action(self._rpc_call, [])
e1ab82613133 backend: replace Pylons with TurboGears2
Alessandro Molina <alessandro.molina@axant.it>
parents: 6553
diff changeset
212 state.set_params(self._rpc_args)
e1ab82613133 backend: replace Pylons with TurboGears2
Alessandro Molina <alessandro.molina@axant.it>
parents: 6553
diff changeset
213 return state
e1ab82613133 backend: replace Pylons with TurboGears2
Alessandro Molina <alessandro.molina@axant.it>
parents: 6553
diff changeset
214
e1ab82613133 backend: replace Pylons with TurboGears2
Alessandro Molina <alessandro.molina@axant.it>
parents: 6553
diff changeset
215 def _rpc_call(self, action, environ, **rpc_args):
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
216 """
6569
e1ab82613133 backend: replace Pylons with TurboGears2
Alessandro Molina <alessandro.molina@axant.it>
parents: 6553
diff changeset
217 Call the specified RPC Method
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
218 """
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3179
diff changeset
219 raw_response = ''
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
220 try:
6569
e1ab82613133 backend: replace Pylons with TurboGears2
Alessandro Molina <alessandro.molina@axant.it>
parents: 6553
diff changeset
221 raw_response = getattr(self, action)(**rpc_args)
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
222 if isinstance(raw_response, HTTPError):
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
223 self._error = str(raw_response)
5374
d69aa464f373 cleanup: consistently use 'except ... as ...:'
Mads Kiilerich <madski@unity3d.com>
parents: 5326
diff changeset
224 except JSONRPCError as e:
8201
620c13a373c5 py3: trivial renaming of unicode to str
Mads Kiilerich <mads@kiilerich.com>
parents: 8196
diff changeset
225 self._error = str(e)
5374
d69aa464f373 cleanup: consistently use 'except ... as ...:'
Mads Kiilerich <madski@unity3d.com>
parents: 5326
diff changeset
226 except Exception as e:
5375
0210d0b769d4 cleanup: pass log strings unformatted - avoid unnecessary % formatting when not logging
Mads Kiilerich <madski@unity3d.com>
parents: 5374
diff changeset
227 log.error('Encountered unhandled exception: %s',
0210d0b769d4 cleanup: pass log strings unformatted - avoid unnecessary % formatting when not logging
Mads Kiilerich <madski@unity3d.com>
parents: 5374
diff changeset
228 traceback.format_exc(),)
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
229 json_exc = JSONRPCError('Internal server error')
8201
620c13a373c5 py3: trivial renaming of unicode to str
Mads Kiilerich <mads@kiilerich.com>
parents: 8196
diff changeset
230 self._error = str(json_exc)
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
231
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
232 if self._error is not None:
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
233 raw_response = None
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
234
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3179
diff changeset
235 response = dict(id=self._req_id, result=raw_response, error=self._error)
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
236 try:
8120
58b6e4cd6fe9 lib: clean up ext_json and how it is used - avoid monkey patching
Mads Kiilerich <mads@kiilerich.com>
parents: 8074
diff changeset
237 return ascii_bytes(ext_json.dumps(response))
5374
d69aa464f373 cleanup: consistently use 'except ... as ...:'
Mads Kiilerich <madski@unity3d.com>
parents: 5326
diff changeset
238 except TypeError as e:
8074
4780af2c6ff2 api: better error logging for API usage errors - say which request failed to encode response
Mads Kiilerich <mads@kiilerich.com>
parents: 8068
diff changeset
239 log.error('API FAILED. Error encoding response for %s %s: %s\n%s', action, rpc_args, e, traceback.format_exc())
8120
58b6e4cd6fe9 lib: clean up ext_json and how it is used - avoid monkey patching
Mads Kiilerich <mads@kiilerich.com>
parents: 8074
diff changeset
240 return ascii_bytes(ext_json.dumps(
1796
6274adc06988 fixed RPC call for api that was missing request id
Marcin Kuzminski <marcin@python-works.com>
parents: 1793
diff changeset
241 dict(
2151
12ceeda33339 #404 API extensions for showing permission for users
Marcin Kuzminski <marcin@python-works.com>
parents: 1976
diff changeset
242 id=self._req_id,
1796
6274adc06988 fixed RPC call for api that was missing request id
Marcin Kuzminski <marcin@python-works.com>
parents: 1793
diff changeset
243 result=None,
8120
58b6e4cd6fe9 lib: clean up ext_json and how it is used - avoid monkey patching
Mads Kiilerich <mads@kiilerich.com>
parents: 8074
diff changeset
244 error="Error encoding response",
1796
6274adc06988 fixed RPC call for api that was missing request id
Marcin Kuzminski <marcin@python-works.com>
parents: 1793
diff changeset
245 )
8120
58b6e4cd6fe9 lib: clean up ext_json and how it is used - avoid monkey patching
Mads Kiilerich <mads@kiilerich.com>
parents: 8074
diff changeset
246 ))
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
247
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
248 def _find_method(self):
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
249 """
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
250 Return method named by `self._req_method` in controller if able
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
251 """
5375
0210d0b769d4 cleanup: pass log strings unformatted - avoid unnecessary % formatting when not logging
Mads Kiilerich <madski@unity3d.com>
parents: 5374
diff changeset
252 log.debug('Trying to find JSON-RPC method: %s', self._req_method)
1445
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
253 if self._req_method.startswith('_'):
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
254 raise AttributeError("Method not allowed")
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
255
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
256 try:
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
257 func = getattr(self, self._req_method, None)
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
258 except UnicodeEncodeError:
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
259 raise AttributeError("Problem decoding unicode in requested "
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
260 "method name.")
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
261
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
262 if isinstance(func, types.MethodType):
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
263 return func
c78f6bf52e9c Beginning of API implementation for rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
264 else:
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3179
diff changeset
265 raise AttributeError("No such method: %s" % (self._req_method,))