@@ -20,12 +20,14 @@ fixes
- fixed git protocol issues with repos-groups
- fixed git remote repos validator that prevented from cloning remote git repos
- fixes #370 ending slashes fixes for repo and groups
- fixes #368 improved git-protocol detection to handle other clients
- fixes #366 When Setting Repository Group To Blank Repo Group Wont Be
Moved To Root
- fixes #371 fixed issues with beaker/sqlalchemy and non-ascii cache keys
1.3.1 (**2012-02-27**)
----------------------
news
++++
@@ -21,12 +21,13 @@ Beaker constructs.
import beaker
from beaker.exceptions import BeakerException
from sqlalchemy.orm.interfaces import MapperOption
from sqlalchemy.orm.query import Query
from sqlalchemy.sql import visitors
from rhodecode.lib import safe_str
class CachingQuery(Query):
"""A Query subclass which optionally loads full results from a Beaker
cache region.
@@ -134,15 +135,16 @@ def _get_cache_parameters(query):
region, namespace, cache_key = query._cache_parameters
namespace = _namespace_from_query(namespace, query)
if cache_key is None:
# cache key - the value arguments from this query's parameters.
args = [str(x) for x in _params_from_query(query)]
args.extend(filter(lambda k:k not in ['None', None, u'None'],
args = [safe_str(x) for x in _params_from_query(query)]
args.extend(filter(lambda k: k not in ['None', None, u'None'],
[str(query._limit), str(query._offset)]))
cache_key = " ".join(args)
raise Exception('Cache key cannot be None')
# get cache
@@ -41,20 +41,23 @@ from rhodecode.lib.vcs.utils.lazy import
from rhodecode.lib import str2bool, safe_str, get_changeset_safe, safe_unicode
from rhodecode.lib.compat import json
from rhodecode.lib.caching_query import FromCache
from rhodecode.model.meta import Base, Session
import hashlib
log = logging.getLogger(__name__)
#==============================================================================
# BASE CLASSES
_hash_key = lambda k: hashlib.md5(safe_str(k)).hexdigest()
class ModelSerializer(json.JSONEncoder):
"""
Simple Serializer for JSON,
usage::
@@ -334,14 +337,17 @@ class User(Base, BaseModel):
if case_insensitive:
q = cls.query().filter(cls.username.ilike(username))
else:
q = cls.query().filter(cls.username == username)
if cache:
q = q.options(FromCache("sql_cache_short",
"get_user_%s" % username))
q = q.options(FromCache(
"sql_cache_short",
"get_user_%s" % _hash_key(username)
)
return q.scalar()
@classmethod
def get_by_api_key(cls, api_key, cache=False):
q = cls.query().filter(cls.api_key == api_key)
@@ -415,14 +421,17 @@ class UsersGroup(Base, BaseModel):
case_insensitive=False):
q = cls.query().filter(cls.users_group_name.ilike(group_name))
q = cls.query().filter(cls.users_group_name == group_name)
"get_user_%s" % group_name))
"get_user_%s" % _hash_key(group_name)
def get(cls, users_group_id, cache=False):
users_group = cls.query()
@@ -745,14 +754,17 @@ class RepoGroup(Base, BaseModel):
gr = cls.query()\
.filter(cls.group_name.ilike(group_name))
.filter(cls.group_name == group_name)
gr = gr.options(FromCache("sql_cache_short",
"get_group_%s" % group_name))
gr = gr.options(FromCache(
"get_group_%s" % _hash_key(group_name)
return gr.scalar()
@property
def parents(self):
parents_recursion_limit = 5
groups = []
Status change: