##// END OF EJS Templates
fixes #371 fixed issues with beaker/sqlalchemy and non-ascii cache keys
marcink -
r2062:bf8ed0ad beta
parent child Browse files
Show More
@@ -23,6 +23,8 b' fixes'
23 23 - fixes #368 improved git-protocol detection to handle other clients
24 24 - fixes #366 When Setting Repository Group To Blank Repo Group Wont Be
25 25 Moved To Root
26 - fixes #371 fixed issues with beaker/sqlalchemy and non-ascii cache keys
27
26 28
27 29 1.3.1 (**2012-02-27**)
28 30 ----------------------
@@ -24,6 +24,7 b' from beaker.exceptions import BeakerExce'
24 24 from sqlalchemy.orm.interfaces import MapperOption
25 25 from sqlalchemy.orm.query import Query
26 26 from sqlalchemy.sql import visitors
27 from rhodecode.lib import safe_str
27 28
28 29
29 30 class CachingQuery(Query):
@@ -137,9 +138,10 b' def _get_cache_parameters(query):'
137 138
138 139 if cache_key is None:
139 140 # cache key - the value arguments from this query's parameters.
140 args = [str(x) for x in _params_from_query(query)]
141 args = [safe_str(x) for x in _params_from_query(query)]
141 142 args.extend(filter(lambda k:k not in ['None', None, u'None'],
142 143 [str(query._limit), str(query._offset)]))
144
143 145 cache_key = " ".join(args)
144 146
145 147 if cache_key is None:
@@ -44,6 +44,7 b' from rhodecode.lib.compat import json'
44 44 from rhodecode.lib.caching_query import FromCache
45 45
46 46 from rhodecode.model.meta import Base, Session
47 import hashlib
47 48
48 49
49 50 log = logging.getLogger(__name__)
@@ -52,6 +53,8 b' log = logging.getLogger(__name__)'
52 53 # BASE CLASSES
53 54 #==============================================================================
54 55
56 _hash_key = lambda k: hashlib.md5(safe_str(k)).hexdigest()
57
55 58
56 59 class ModelSerializer(json.JSONEncoder):
57 60 """
@@ -337,8 +340,11 b' class User(Base, BaseModel):'
337 340 q = cls.query().filter(cls.username == username)
338 341
339 342 if cache:
340 q = q.options(FromCache("sql_cache_short",
341 "get_user_%s" % username))
343 q = q.options(FromCache(
344 "sql_cache_short",
345 "get_user_%s" % _hash_key(username)
346 )
347 )
342 348 return q.scalar()
343 349
344 350 @classmethod
@@ -418,8 +424,11 b' class UsersGroup(Base, BaseModel):'
418 424 else:
419 425 q = cls.query().filter(cls.users_group_name == group_name)
420 426 if cache:
421 q = q.options(FromCache("sql_cache_short",
422 "get_user_%s" % group_name))
427 q = q.options(FromCache(
428 "sql_cache_short",
429 "get_user_%s" % _hash_key(group_name)
430 )
431 )
423 432 return q.scalar()
424 433
425 434 @classmethod
@@ -748,8 +757,11 b' class RepoGroup(Base, BaseModel):'
748 757 gr = cls.query()\
749 758 .filter(cls.group_name == group_name)
750 759 if cache:
751 gr = gr.options(FromCache("sql_cache_short",
752 "get_group_%s" % group_name))
760 gr = gr.options(FromCache(
761 "sql_cache_short",
762 "get_group_%s" % _hash_key(group_name)
763 )
764 )
753 765 return gr.scalar()
754 766
755 767 @property
General Comments 0
You need to be logged in to leave comments. Login now