Show More
@@ -36,9 +36,6 b' from functools import wraps' | |||||
36 | import ipaddress |
|
36 | import ipaddress | |
37 | from beaker.cache import cache_region |
|
37 | from beaker.cache import cache_region | |
38 | from pyramid.httpexceptions import HTTPForbidden, HTTPFound, HTTPNotFound |
|
38 | from pyramid.httpexceptions import HTTPForbidden, HTTPFound, HTTPNotFound | |
39 | from pylons.i18n.translation import _ |
|
|||
40 | # NOTE(marcink): this has to be removed only after pyramid migration, |
|
|||
41 | # replace with _ = request.translate |
|
|||
42 | from sqlalchemy.orm.exc import ObjectDeletedError |
|
39 | from sqlalchemy.orm.exc import ObjectDeletedError | |
43 | from sqlalchemy.orm import joinedload |
|
40 | from sqlalchemy.orm import joinedload | |
44 | from zope.cachedescriptors.property import Lazy as LazyProperty |
|
41 | from zope.cachedescriptors.property import Lazy as LazyProperty | |
@@ -1325,7 +1322,7 b' def get_csrf_token(session, force_new=Fa' | |||||
1325 | Return the current authentication token, creating one if one doesn't |
|
1322 | Return the current authentication token, creating one if one doesn't | |
1326 | already exist and the save_if_missing flag is present. |
|
1323 | already exist and the save_if_missing flag is present. | |
1327 |
|
1324 | |||
1328 |
:param session: pass in the py |
|
1325 | :param session: pass in the pyramid session, else we use the global ones | |
1329 | :param force_new: force to re-generate the token and store it in session |
|
1326 | :param force_new: force to re-generate the token and store it in session | |
1330 | :param save_if_missing: save the newly generated token if it's missing in |
|
1327 | :param save_if_missing: save the newly generated token if it's missing in | |
1331 | session |
|
1328 | session | |
@@ -1344,11 +1341,6 b' def get_csrf_token(session, force_new=Fa' | |||||
1344 | def get_request(perm_class_instance): |
|
1341 | def get_request(perm_class_instance): | |
1345 | from pyramid.threadlocal import get_current_request |
|
1342 | from pyramid.threadlocal import get_current_request | |
1346 | pyramid_request = get_current_request() |
|
1343 | pyramid_request = get_current_request() | |
1347 | if not pyramid_request: |
|
|||
1348 | # return global request of pylons in case pyramid isn't available |
|
|||
1349 | # NOTE(marcink): this should be removed after migration to pyramid |
|
|||
1350 | from pylons import request |
|
|||
1351 | return request |
|
|||
1352 | return pyramid_request |
|
1344 | return pyramid_request | |
1353 |
|
1345 | |||
1354 |
|
1346 | |||
@@ -1436,6 +1428,7 b' class LoginRequired(object):' | |||||
1436 | cls = fargs[0] |
|
1428 | cls = fargs[0] | |
1437 | user = cls._rhodecode_user |
|
1429 | user = cls._rhodecode_user | |
1438 | request = self._get_request() |
|
1430 | request = self._get_request() | |
|
1431 | _ = request.translate | |||
1439 |
|
1432 | |||
1440 | loc = "%s:%s" % (cls.__class__.__name__, func.__name__) |
|
1433 | loc = "%s:%s" % (cls.__class__.__name__, func.__name__) | |
1441 | log.debug('Starting login restriction checks for user: %s' % (user,)) |
|
1434 | log.debug('Starting login restriction checks for user: %s' % (user,)) | |
@@ -1525,7 +1518,7 b' class NotAnonymous(object):' | |||||
1525 | cls = fargs[0] |
|
1518 | cls = fargs[0] | |
1526 | self.user = cls._rhodecode_user |
|
1519 | self.user = cls._rhodecode_user | |
1527 | request = self._get_request() |
|
1520 | request = self._get_request() | |
1528 |
|
1521 | _ = request.translate | ||
1529 | log.debug('Checking if user is not anonymous @%s' % cls) |
|
1522 | log.debug('Checking if user is not anonymous @%s' % cls) | |
1530 |
|
1523 | |||
1531 | anonymous = self.user.username == User.DEFAULT_USER |
|
1524 | anonymous = self.user.username == User.DEFAULT_USER | |
@@ -1560,6 +1553,8 b' class PermsDecorator(object):' | |||||
1560 | import rhodecode.lib.helpers as h |
|
1553 | import rhodecode.lib.helpers as h | |
1561 | cls = fargs[0] |
|
1554 | cls = fargs[0] | |
1562 | _user = cls._rhodecode_user |
|
1555 | _user = cls._rhodecode_user | |
|
1556 | request = self._get_request() | |||
|
1557 | _ = request.translate | |||
1563 |
|
1558 | |||
1564 | log.debug('checking %s permissions %s for %s %s', |
|
1559 | log.debug('checking %s permissions %s for %s %s', | |
1565 | self.__class__.__name__, self.required_perms, cls, _user) |
|
1560 | self.__class__.__name__, self.required_perms, cls, _user) |
General Comments 0
You need to be logged in to leave comments.
Login now