annotate rhodecode/lib/caching_query.py @ 2407:8a68e0292232 beta

Change git & hg hooks to post. They shouldn't block as they are used just for logging actions. Futhermore post hooks have access to changesets, so it's much better flexible
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 06 Jun 2012 22:23:27 +0200
parents 8ecfed1d8f8b
children 7e5f8c12a3fc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
1 """caching_query.py
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
2
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
3 Represent persistence structures which allow the usage of
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
4 Beaker caching with SQLAlchemy.
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
5
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6 The three new concepts introduced here are:
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8 * CachingQuery - a Query subclass that caches and
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
9 retrieves results in/from Beaker.
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10 * FromCache - a query option that establishes caching
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
11 parameters on a Query
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12 * RelationshipCache - a variant of FromCache which is specific
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
13 to a query invoked during a lazy load.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
14 * _params_from_query - extracts value parameters from
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
15 a Query.
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
16
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
17 The rest of what's here are standard SQLAlchemy and
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
18 Beaker constructs.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
19
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
20 """
1271
aa7e45ad0cea Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
21 import beaker
609
c1c1cf772337 moved out sqlalchemy cache from meta to the config files.
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
22 from beaker.exceptions import BeakerException
1271
aa7e45ad0cea Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
23
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
24 from sqlalchemy.orm.interfaces import MapperOption
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
25 from sqlalchemy.orm.query import Query
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
26 from sqlalchemy.sql import visitors
2109
8ecfed1d8f8b utils/conf
Marcin Kuzminski <marcin@python-works.com>
parents: 2062
diff changeset
27 from rhodecode.lib.utils2 import safe_str
1271
aa7e45ad0cea Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
28
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
29
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
30 class CachingQuery(Query):
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
31 """A Query subclass which optionally loads full results from a Beaker
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
32 cache region.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
33
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
34 The CachingQuery stores additional state that allows it to consult
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
35 a Beaker cache before accessing the database:
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
36
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
37 * A "region", which is a cache region argument passed to a
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
38 Beaker CacheManager, specifies a particular cache configuration
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
39 (including backend implementation, expiration times, etc.)
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
40 * A "namespace", which is a qualifying name that identifies a
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
41 group of keys within the cache. A query that filters on a name
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
42 might use the name "by_name", a query that filters on a date range
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
43 to a joined table might use the name "related_date_range".
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
44
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
45 When the above state is present, a Beaker cache is retrieved.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
46
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
47 The "namespace" name is first concatenated with
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
48 a string composed of the individual entities and columns the Query
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49 requests, i.e. such as ``Query(User.id, User.name)``.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
50
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51 The Beaker cache is then loaded from the cache manager based
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
52 on the region and composed namespace. The key within the cache
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
53 itself is then constructed against the bind parameters specified
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
54 by this query, which are usually literals defined in the
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
55 WHERE clause.
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
56
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
57 The FromCache and RelationshipCache mapper options below represent
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
58 the "public" method of configuring this state upon the CachingQuery.
1046
9e93cad9357b fixed caching query to propagate data_dir default from beaker
Marcin Kuzminski <marcin@python-works.com>
parents: 784
diff changeset
59
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
60 """
784
30d3161c6683 Implemented fancier top menu for logged and anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents: 610
diff changeset
61
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
62 def __init__(self, manager, *args, **kw):
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
63 self.cache_manager = manager
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
64 Query.__init__(self, *args, **kw)
784
30d3161c6683 Implemented fancier top menu for logged and anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents: 610
diff changeset
65
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
66 def __iter__(self):
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
67 """override __iter__ to pull results from Beaker
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
68 if particular attributes have been configured.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
69
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
70 Note that this approach does *not* detach the loaded objects from
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
71 the current session. If the cache backend is an in-process cache
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
72 (like "memory") and lives beyond the scope of the current session's
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
73 transaction, those objects may be expired. The method here can be
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
74 modified to first expunge() each loaded item from the current
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
75 session before returning the list of items, so that the items
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
76 in the cache are not the same ones in the current Session.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
77
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
78 """
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
79 if hasattr(self, '_cache_parameters'):
1271
aa7e45ad0cea Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
80 return self.get_value(createfunc=lambda:
aa7e45ad0cea Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
81 list(Query.__iter__(self)))
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
82 else:
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
83 return Query.__iter__(self)
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
84
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
85 def invalidate(self):
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
86 """Invalidate the value represented by this Query."""
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
87
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
88 cache, cache_key = _get_cache_parameters(self)
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
89 cache.remove(cache_key)
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
90
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
91 def get_value(self, merge=True, createfunc=None):
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
92 """Return the value from the cache for this query.
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
93
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
94 Raise KeyError if no value present and no
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
95 createfunc specified.
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
96
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
97 """
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
98 cache, cache_key = _get_cache_parameters(self)
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
99 ret = cache.get_value(cache_key, createfunc=createfunc)
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
100 if merge:
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
101 ret = self.merge_result(ret, load=False)
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
102 return ret
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
103
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
104 def set_value(self, value):
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
105 """Set the value in the cache for this query."""
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
106
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
107 cache, cache_key = _get_cache_parameters(self)
784
30d3161c6683 Implemented fancier top menu for logged and anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents: 610
diff changeset
108 cache.put(cache_key, value)
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
109
1271
aa7e45ad0cea Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
110
1339
e861eb1c4a2f update caching_query from latest sqlalchemy
Marcin Kuzminski <marcin@python-works.com>
parents: 1271
diff changeset
111 def query_callable(manager, query_cls=CachingQuery):
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
112 def query(*arg, **kw):
1339
e861eb1c4a2f update caching_query from latest sqlalchemy
Marcin Kuzminski <marcin@python-works.com>
parents: 1271
diff changeset
113 return query_cls(manager, *arg, **kw)
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
114 return query
609
c1c1cf772337 moved out sqlalchemy cache from meta to the config files.
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
115
1271
aa7e45ad0cea Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
116
609
c1c1cf772337 moved out sqlalchemy cache from meta to the config files.
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
117 def get_cache_region(name, region):
610
b0a411f5ec70 fixed error message about cache settings
Marcin Kuzminski <marcin@python-works.com>
parents: 609
diff changeset
118 if region not in beaker.cache.cache_regions:
784
30d3161c6683 Implemented fancier top menu for logged and anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents: 610
diff changeset
119 raise BeakerException('Cache region `%s` not configured '
610
b0a411f5ec70 fixed error message about cache settings
Marcin Kuzminski <marcin@python-works.com>
parents: 609
diff changeset
120 'Check if proper cache settings are in the .ini files' % region)
b0a411f5ec70 fixed error message about cache settings
Marcin Kuzminski <marcin@python-works.com>
parents: 609
diff changeset
121 kw = beaker.cache.cache_regions[region]
b0a411f5ec70 fixed error message about cache settings
Marcin Kuzminski <marcin@python-works.com>
parents: 609
diff changeset
122 return beaker.cache.Cache._get_cache(name, kw)
784
30d3161c6683 Implemented fancier top menu for logged and anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents: 610
diff changeset
123
1271
aa7e45ad0cea Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
124
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
125 def _get_cache_parameters(query):
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
126 """For a query with cache_region and cache_namespace configured,
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
127 return the correspoinding Cache instance and cache key, based
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
128 on this query's current criterion and parameter values.
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
129
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
130 """
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
131 if not hasattr(query, '_cache_parameters'):
1271
aa7e45ad0cea Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
132 raise ValueError("This Query does not have caching "
aa7e45ad0cea Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
133 "parameters configured.")
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
134
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
135 region, namespace, cache_key = query._cache_parameters
784
30d3161c6683 Implemented fancier top menu for logged and anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents: 610
diff changeset
136
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
137 namespace = _namespace_from_query(namespace, query)
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
138
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
139 if cache_key is None:
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
140 # cache key - the value arguments from this query's parameters.
2062
bf8ed0adbc66 fixes #371 fixed issues with beaker/sqlalchemy and non-ascii cache keys
Marcin Kuzminski <marcin@python-works.com>
parents: 1727
diff changeset
141 args = [safe_str(x) for x in _params_from_query(query)]
bf8ed0adbc66 fixes #371 fixed issues with beaker/sqlalchemy and non-ascii cache keys
Marcin Kuzminski <marcin@python-works.com>
parents: 1727
diff changeset
142 args.extend(filter(lambda k: k not in ['None', None, u'None'],
1727
8e9f51091229 fixed caching query on repos path
Marcin Kuzminski <marcin@python-works.com>
parents: 1669
diff changeset
143 [str(query._limit), str(query._offset)]))
2062
bf8ed0adbc66 fixes #371 fixed issues with beaker/sqlalchemy and non-ascii cache keys
Marcin Kuzminski <marcin@python-works.com>
parents: 1727
diff changeset
144
1727
8e9f51091229 fixed caching query on repos path
Marcin Kuzminski <marcin@python-works.com>
parents: 1669
diff changeset
145 cache_key = " ".join(args)
8e9f51091229 fixed caching query on repos path
Marcin Kuzminski <marcin@python-works.com>
parents: 1669
diff changeset
146
8e9f51091229 fixed caching query on repos path
Marcin Kuzminski <marcin@python-works.com>
parents: 1669
diff changeset
147 if cache_key is None:
8e9f51091229 fixed caching query on repos path
Marcin Kuzminski <marcin@python-works.com>
parents: 1669
diff changeset
148 raise Exception('Cache key cannot be None')
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
149
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
150 # get cache
609
c1c1cf772337 moved out sqlalchemy cache from meta to the config files.
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
151 #cache = query.cache_manager.get_cache_region(namespace, region)
c1c1cf772337 moved out sqlalchemy cache from meta to the config files.
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
152 cache = get_cache_region(namespace, region)
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
153 # optional - hash the cache_key too for consistent length
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
154 # import uuid
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
155 # cache_key= str(uuid.uuid5(uuid.NAMESPACE_DNS, cache_key))
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
156
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
157 return cache, cache_key
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
158
1271
aa7e45ad0cea Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
159
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
160 def _namespace_from_query(namespace, query):
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
161 # cache namespace - the token handed in by the
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
162 # option + class we're querying against
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
163 namespace = " ".join([namespace] + [str(x) for x in query._entities])
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
164
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
165 # memcached wants this
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
166 namespace = namespace.replace(' ', '_')
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
167
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
168 return namespace
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
169
1271
aa7e45ad0cea Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
170
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
171 def _set_cache_parameters(query, region, namespace, cache_key):
784
30d3161c6683 Implemented fancier top menu for logged and anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents: 610
diff changeset
172
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
173 if hasattr(query, '_cache_parameters'):
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
174 region, namespace, cache_key = query._cache_parameters
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
175 raise ValueError("This query is already configured "
784
30d3161c6683 Implemented fancier top menu for logged and anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents: 610
diff changeset
176 "for region %r namespace %r" %
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
177 (region, namespace)
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
178 )
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
179 query._cache_parameters = region, namespace, cache_key
784
30d3161c6683 Implemented fancier top menu for logged and anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents: 610
diff changeset
180
1271
aa7e45ad0cea Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
181
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
182 class FromCache(MapperOption):
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
183 """Specifies that a Query should load results from a cache."""
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
184
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
185 propagate_to_loaders = False
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
186
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
187 def __init__(self, region, namespace, cache_key=None):
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
188 """Construct a new FromCache.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
189
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
190 :param region: the cache region. Should be a
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
191 region configured in the Beaker CacheManager.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
192
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
193 :param namespace: the cache namespace. Should
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
194 be a name uniquely describing the target Query's
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
195 lexical structure.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
196
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
197 :param cache_key: optional. A string cache key
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
198 that will serve as the key to the query. Use this
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
199 if your query has a huge amount of parameters (such
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
200 as when using in_()) which correspond more simply to
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
201 some other identifier.
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
202
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
203 """
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
204 self.region = region
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
205 self.namespace = namespace
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
206 self.cache_key = cache_key
784
30d3161c6683 Implemented fancier top menu for logged and anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents: 610
diff changeset
207
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
208 def process_query(self, query):
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
209 """Process a Query during normal loading operation."""
784
30d3161c6683 Implemented fancier top menu for logged and anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents: 610
diff changeset
210
1271
aa7e45ad0cea Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
211 _set_cache_parameters(query, self.region, self.namespace,
aa7e45ad0cea Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
212 self.cache_key)
aa7e45ad0cea Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
213
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
214
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
215 class RelationshipCache(MapperOption):
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
216 """Specifies that a Query as called within a "lazy load"
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
217 should load results from a cache."""
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
218
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
219 propagate_to_loaders = True
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
220
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
221 def __init__(self, region, namespace, attribute):
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
222 """Construct a new RelationshipCache.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
223
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
224 :param region: the cache region. Should be a
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
225 region configured in the Beaker CacheManager.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
226
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
227 :param namespace: the cache namespace. Should
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
228 be a name uniquely describing the target Query's
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
229 lexical structure.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
230
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
231 :param attribute: A Class.attribute which
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
232 indicates a particular class relationship() whose
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
233 lazy loader should be pulled from the cache.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
234
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
235 """
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
236 self.region = region
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
237 self.namespace = namespace
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
238 self._relationship_options = {
1271
aa7e45ad0cea Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
239 (attribute.property.parent.class_, attribute.property.key): self
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
240 }
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
241
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
242 def process_query_conditionally(self, query):
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
243 """Process a Query that is used within a lazy loader.
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
244
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
245 (the process_query_conditionally() method is a SQLAlchemy
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
246 hook invoked only within lazyload.)
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
247
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
248 """
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
249 if query._current_path:
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
250 mapper, key = query._current_path[-2:]
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
251
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
252 for cls in mapper.class_.__mro__:
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
253 if (cls, key) in self._relationship_options:
1271
aa7e45ad0cea Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
254 relationship_option = \
aa7e45ad0cea Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
255 self._relationship_options[(cls, key)]
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
256 _set_cache_parameters(
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
257 query,
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
258 relationship_option.region,
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
259 relationship_option.namespace,
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
260 None)
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
261
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
262 def and_(self, option):
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
263 """Chain another RelationshipCache option to this one.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
264
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
265 While many RelationshipCache objects can be specified on a single
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
266 Query separately, chaining them together allows for a more efficient
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
267 lookup during load.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
268
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
269 """
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
270 self._relationship_options.update(option._relationship_options)
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
271 return self
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
272
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
273
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
274 def _params_from_query(query):
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
275 """Pull the bind parameter values from a query.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
276
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
277 This takes into account any scalar attribute bindparam set up.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
278
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
279 E.g. params_from_query(query.filter(Cls.foo==5).filter(Cls.bar==7)))
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
280 would return [5, 7].
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1046
diff changeset
281
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
282 """
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
283 v = []
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
284 def visit_bindparam(bind):
1365
cd865113423e applied caching query update from latest sqlalchemy
Marcin Kuzminski <marcin@python-works.com>
parents: 1339
diff changeset
285
1727
8e9f51091229 fixed caching query on repos path
Marcin Kuzminski <marcin@python-works.com>
parents: 1669
diff changeset
286 if bind.key in query._params:
8e9f51091229 fixed caching query on repos path
Marcin Kuzminski <marcin@python-works.com>
parents: 1669
diff changeset
287 value = query._params[bind.key]
8e9f51091229 fixed caching query on repos path
Marcin Kuzminski <marcin@python-works.com>
parents: 1669
diff changeset
288 elif bind.callable:
8e9f51091229 fixed caching query on repos path
Marcin Kuzminski <marcin@python-works.com>
parents: 1669
diff changeset
289 # lazyloader may dig a callable in here, intended
8e9f51091229 fixed caching query on repos path
Marcin Kuzminski <marcin@python-works.com>
parents: 1669
diff changeset
290 # to late-evaluate params after autoflush is called.
8e9f51091229 fixed caching query on repos path
Marcin Kuzminski <marcin@python-works.com>
parents: 1669
diff changeset
291 # convert to a scalar value.
8e9f51091229 fixed caching query on repos path
Marcin Kuzminski <marcin@python-works.com>
parents: 1669
diff changeset
292 value = bind.callable()
8e9f51091229 fixed caching query on repos path
Marcin Kuzminski <marcin@python-works.com>
parents: 1669
diff changeset
293 else:
8e9f51091229 fixed caching query on repos path
Marcin Kuzminski <marcin@python-works.com>
parents: 1669
diff changeset
294 value = bind.value
784
30d3161c6683 Implemented fancier top menu for logged and anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents: 610
diff changeset
295
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
296 v.append(value)
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
297 if query._criterion is not None:
1339
e861eb1c4a2f update caching_query from latest sqlalchemy
Marcin Kuzminski <marcin@python-works.com>
parents: 1271
diff changeset
298 visitors.traverse(query._criterion, {}, {'bindparam':visit_bindparam})
1727
8e9f51091229 fixed caching query on repos path
Marcin Kuzminski <marcin@python-works.com>
parents: 1669
diff changeset
299 for f in query._from_obj:
8e9f51091229 fixed caching query on repos path
Marcin Kuzminski <marcin@python-works.com>
parents: 1669
diff changeset
300 visitors.traverse(f, {}, {'bindparam':visit_bindparam})
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
301 return v