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