Show More
@@ -113,7 +113,15 b' OUTPUT::' | |||
|
113 | 113 | "email" : "<email>", |
|
114 | 114 | "active" : "<bool>", |
|
115 | 115 | "admin" : "<bool>", |
|
116 | "ldap_dn" : "<ldap_dn>" | |
|
116 | "ldap_dn" : "<ldap_dn>", | |
|
117 | "last_login": "<last_login>", | |
|
118 | "permissions": { | |
|
119 | "global": ["hg.create.repository", | |
|
120 | "repository.read", | |
|
121 | "hg.register.manual_activate"], | |
|
122 | "repositories": {"repo1": "repository.none"}, | |
|
123 | "repositories_groups": {"Group1": "group.read"} | |
|
124 | }, | |
|
117 | 125 | } |
|
118 | 126 | |
|
119 | 127 | error: null |
@@ -144,7 +152,8 b' OUTPUT::' | |||
|
144 | 152 | "email" : "<email>", |
|
145 | 153 | "active" : "<bool>", |
|
146 | 154 | "admin" : "<bool>", |
|
147 | "ldap_dn" : "<ldap_dn>" | |
|
155 | "ldap_dn" : "<ldap_dn>", | |
|
156 | "last_login": "<last_login>", | |
|
148 | 157 | }, |
|
149 | 158 | … |
|
150 | 159 | ] |
@@ -43,6 +43,8 b' fixes' | |||
|
43 | 43 | - fixed #393 py2.5 fixes for routes url generator |
|
44 | 44 | - fixed #397 Private repository groups shows up before login |
|
45 | 45 | - fixed #396 fixed problems with revoking users in nested groups |
|
46 | - fixed mysql unicode issues + specified InnoDB as default engine with | |
|
47 | utf8 charset | |
|
46 | 48 | |
|
47 | 49 | 1.3.3 (**2012-03-02**) |
|
48 | 50 | ---------------------- |
@@ -233,10 +233,10 b' class JSONRPCController(WSGIController):' | |||
|
233 | 233 | try: |
|
234 | 234 | return json.dumps(response) |
|
235 | 235 | except TypeError, e: |
|
236 |
log. |
|
|
236 | log.error('API FAILED. Error encoding response: %s' % e) | |
|
237 | 237 | return json.dumps( |
|
238 | 238 | dict( |
|
239 | self._req_id, | |
|
239 | id=self._req_id, | |
|
240 | 240 | result=None, |
|
241 | 241 | error="Error encoding response" |
|
242 | 242 | ) |
@@ -30,18 +30,16 b' import logging' | |||
|
30 | 30 | |
|
31 | 31 | from rhodecode.controllers.api import JSONRPCController, JSONRPCError |
|
32 | 32 | from rhodecode.lib.auth import HasPermissionAllDecorator, \ |
|
33 | HasPermissionAnyDecorator, PasswordGenerator | |
|
33 | HasPermissionAnyDecorator, PasswordGenerator, AuthUser | |
|
34 | 34 | |
|
35 | 35 | from rhodecode.model.meta import Session |
|
36 | 36 | from rhodecode.model.scm import ScmModel |
|
37 |
from rhodecode.model.db import User, UsersGroup, |
|
|
37 | from rhodecode.model.db import User, UsersGroup, Repository | |
|
38 | 38 | from rhodecode.model.repo import RepoModel |
|
39 | 39 | from rhodecode.model.user import UserModel |
|
40 | 40 | from rhodecode.model.users_group import UsersGroupModel |
|
41 | from rhodecode.model.repos_group import ReposGroupModel | |
|
42 | 41 | from rhodecode.lib.utils import map_groups |
|
43 | 42 | |
|
44 | ||
|
45 | 43 | log = logging.getLogger(__name__) |
|
46 | 44 | |
|
47 | 45 | |
@@ -101,7 +99,9 b' class ApiController(JSONRPCController):' | |||
|
101 | 99 | email=user.email, |
|
102 | 100 | active=user.active, |
|
103 | 101 | admin=user.admin, |
|
104 | ldap_dn=user.ldap_dn | |
|
102 | ldap_dn=user.ldap_dn, | |
|
103 | last_login=user.last_login, | |
|
104 | permissions=AuthUser(user_id=user.user_id).permissions | |
|
105 | 105 | ) |
|
106 | 106 | |
|
107 | 107 | @HasPermissionAllDecorator('hg.admin') |
@@ -123,7 +123,8 b' class ApiController(JSONRPCController):' | |||
|
123 | 123 | email=user.email, |
|
124 | 124 | active=user.active, |
|
125 | 125 | admin=user.admin, |
|
126 | ldap_dn=user.ldap_dn | |
|
126 | ldap_dn=user.ldap_dn, | |
|
127 | last_login=user.last_login, | |
|
127 | 128 | ) |
|
128 | 129 | ) |
|
129 | 130 | return result |
@@ -25,16 +25,55 b'' | |||
|
25 | 25 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
26 | 26 | |
|
27 | 27 | import os |
|
28 | import datetime | |
|
29 | import functools | |
|
28 | 30 | from rhodecode import __platform__, PLATFORM_WIN |
|
29 | 31 | |
|
30 | 32 | #============================================================================== |
|
31 | 33 | # json |
|
32 | 34 | #============================================================================== |
|
35 | ||
|
36 | ||
|
37 | def __obj_dump(obj): | |
|
38 | DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S" | |
|
39 | DATE_FORMAT = "%Y-%m-%d" | |
|
40 | if isinstance(obj, complex): | |
|
41 | return [obj.real, obj.imag] | |
|
42 | elif isinstance(obj, datetime.datetime): | |
|
43 | return obj.strftime(DATETIME_FORMAT) | |
|
44 | elif isinstance(obj, datetime.date): | |
|
45 | return obj.strftime(DATE_FORMAT) | |
|
46 | elif isinstance(obj, set): | |
|
47 | return list(obj) | |
|
48 | elif isinstance(obj, OrderedDict): | |
|
49 | return obj.as_dict() | |
|
50 | else: | |
|
51 | raise NotImplementedError | |
|
52 | ||
|
33 | 53 | try: |
|
34 | 54 | import json |
|
55 | ||
|
56 | # extended JSON encoder for json | |
|
57 | class ExtendedEncoder(json.JSONEncoder): | |
|
58 | def default(self, obj): | |
|
59 | try: | |
|
60 | return __obj_dump(obj) | |
|
61 | except NotImplementedError: | |
|
62 | pass | |
|
63 | return json.JSONEncoder.default(self, obj) | |
|
64 | # monkey-patch JSON encoder to use extended version | |
|
65 | json.dumps = functools.partial(json.dumps, cls=ExtendedEncoder) | |
|
35 | 66 | except ImportError: |
|
36 | 67 | import simplejson as json |
|
37 | 68 | |
|
69 | def extended_encode(obj): | |
|
70 | try: | |
|
71 | return __obj_dump(obj) | |
|
72 | except NotImplementedError: | |
|
73 | pass | |
|
74 | raise TypeError("%r is not JSON serializable" % (obj,)) | |
|
75 | json.dumps = functools.partial(json.dumps, default=extended_encode) | |
|
76 | ||
|
38 | 77 | |
|
39 | 78 | #============================================================================== |
|
40 | 79 | # izip_longest |
@@ -44,11 +83,11 b' try:' | |||
|
44 | 83 | except ImportError: |
|
45 | 84 | import itertools |
|
46 | 85 | |
|
47 |
def izip_longest(*args, **kwds): |
|
|
86 | def izip_longest(*args, **kwds): | |
|
48 | 87 | fillvalue = kwds.get("fillvalue") |
|
49 | 88 | |
|
50 | 89 | def sentinel(counter=([fillvalue] * (len(args) - 1)).pop): |
|
51 | yield counter() # yields the fillvalue, or raises IndexError | |
|
90 | yield counter() # yields the fillvalue, or raises IndexError | |
|
52 | 91 | |
|
53 | 92 | fillers = itertools.repeat(fillvalue) |
|
54 | 93 | iters = [itertools.chain(it, sentinel(), fillers) |
General Comments 0
You need to be logged in to leave comments.
Login now