Show More
@@ -113,7 +113,15 b' OUTPUT::' | |||||
113 | "email" : "<email>", |
|
113 | "email" : "<email>", | |
114 | "active" : "<bool>", |
|
114 | "active" : "<bool>", | |
115 | "admin" : "<bool>", |
|
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 | error: null |
|
127 | error: null | |
@@ -144,7 +152,8 b' OUTPUT::' | |||||
144 | "email" : "<email>", |
|
152 | "email" : "<email>", | |
145 | "active" : "<bool>", |
|
153 | "active" : "<bool>", | |
146 | "admin" : "<bool>", |
|
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 | - fixed #393 py2.5 fixes for routes url generator |
|
43 | - fixed #393 py2.5 fixes for routes url generator | |
44 | - fixed #397 Private repository groups shows up before login |
|
44 | - fixed #397 Private repository groups shows up before login | |
45 | - fixed #396 fixed problems with revoking users in nested groups |
|
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 | 1.3.3 (**2012-03-02**) |
|
49 | 1.3.3 (**2012-03-02**) | |
48 | ---------------------- |
|
50 | ---------------------- |
@@ -233,10 +233,10 b' class JSONRPCController(WSGIController):' | |||||
233 | try: |
|
233 | try: | |
234 | return json.dumps(response) |
|
234 | return json.dumps(response) | |
235 | except TypeError, e: |
|
235 | except TypeError, e: | |
236 |
log. |
|
236 | log.error('API FAILED. Error encoding response: %s' % e) | |
237 | return json.dumps( |
|
237 | return json.dumps( | |
238 | dict( |
|
238 | dict( | |
239 | self._req_id, |
|
239 | id=self._req_id, | |
240 | result=None, |
|
240 | result=None, | |
241 | error="Error encoding response" |
|
241 | error="Error encoding response" | |
242 | ) |
|
242 | ) |
@@ -30,18 +30,16 b' import logging' | |||||
30 |
|
30 | |||
31 | from rhodecode.controllers.api import JSONRPCController, JSONRPCError |
|
31 | from rhodecode.controllers.api import JSONRPCController, JSONRPCError | |
32 | from rhodecode.lib.auth import HasPermissionAllDecorator, \ |
|
32 | from rhodecode.lib.auth import HasPermissionAllDecorator, \ | |
33 | HasPermissionAnyDecorator, PasswordGenerator |
|
33 | HasPermissionAnyDecorator, PasswordGenerator, AuthUser | |
34 |
|
34 | |||
35 | from rhodecode.model.meta import Session |
|
35 | from rhodecode.model.meta import Session | |
36 | from rhodecode.model.scm import ScmModel |
|
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 | from rhodecode.model.repo import RepoModel |
|
38 | from rhodecode.model.repo import RepoModel | |
39 | from rhodecode.model.user import UserModel |
|
39 | from rhodecode.model.user import UserModel | |
40 | from rhodecode.model.users_group import UsersGroupModel |
|
40 | from rhodecode.model.users_group import UsersGroupModel | |
41 | from rhodecode.model.repos_group import ReposGroupModel |
|
|||
42 | from rhodecode.lib.utils import map_groups |
|
41 | from rhodecode.lib.utils import map_groups | |
43 |
|
42 | |||
44 |
|
||||
45 | log = logging.getLogger(__name__) |
|
43 | log = logging.getLogger(__name__) | |
46 |
|
44 | |||
47 |
|
45 | |||
@@ -101,7 +99,9 b' class ApiController(JSONRPCController):' | |||||
101 | email=user.email, |
|
99 | email=user.email, | |
102 | active=user.active, |
|
100 | active=user.active, | |
103 | admin=user.admin, |
|
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 | @HasPermissionAllDecorator('hg.admin') |
|
107 | @HasPermissionAllDecorator('hg.admin') | |
@@ -123,7 +123,8 b' class ApiController(JSONRPCController):' | |||||
123 | email=user.email, |
|
123 | email=user.email, | |
124 | active=user.active, |
|
124 | active=user.active, | |
125 | admin=user.admin, |
|
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 | return result |
|
130 | return result |
@@ -25,16 +25,55 b'' | |||||
25 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
25 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
26 |
|
26 | |||
27 | import os |
|
27 | import os | |
|
28 | import datetime | |||
|
29 | import functools | |||
28 | from rhodecode import __platform__, PLATFORM_WIN |
|
30 | from rhodecode import __platform__, PLATFORM_WIN | |
29 |
|
31 | |||
30 | #============================================================================== |
|
32 | #============================================================================== | |
31 | # json |
|
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 | try: |
|
53 | try: | |
34 | import json |
|
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 | except ImportError: |
|
66 | except ImportError: | |
36 | import simplejson as json |
|
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 | # izip_longest |
|
79 | # izip_longest | |
@@ -44,11 +83,11 b' try:' | |||||
44 | except ImportError: |
|
83 | except ImportError: | |
45 | import itertools |
|
84 | import itertools | |
46 |
|
85 | |||
47 |
def izip_longest(*args, **kwds): |
|
86 | def izip_longest(*args, **kwds): | |
48 | fillvalue = kwds.get("fillvalue") |
|
87 | fillvalue = kwds.get("fillvalue") | |
49 |
|
88 | |||
50 | def sentinel(counter=([fillvalue] * (len(args) - 1)).pop): |
|
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 | fillers = itertools.repeat(fillvalue) |
|
92 | fillers = itertools.repeat(fillvalue) | |
54 | iters = [itertools.chain(it, sentinel(), fillers) |
|
93 | iters = [itertools.chain(it, sentinel(), fillers) |
General Comments 0
You need to be logged in to leave comments.
Login now