0001-misc-keep-data-source-calls-in-request-cache-26612.patch
wcs/data_sources.py | ||
---|---|---|
19 | 19 |
import urlparse |
20 | 20 |
import xml.etree.ElementTree as ET |
21 | 21 | |
22 |
from quixote import get_publisher |
|
22 |
from quixote import get_publisher, get_request
|
|
23 | 23 |
from quixote.html import TemplateIO |
24 | 24 | |
25 | 25 |
from qommon import _ |
... | ... | |
156 | 156 |
if Template.is_template_string(url): |
157 | 157 |
vars = get_publisher().substitutions.get_context_variables() |
158 | 158 |
url = get_variadic_url(url, vars) |
159 | ||
160 |
request = get_request() |
|
161 |
if hasattr(request, 'datasources_cache') and url in request.datasources_cache: |
|
162 |
return request.datasources_cache[url] |
|
163 | ||
159 | 164 |
try: |
160 | 165 |
signature_key, orig = get_secret_and_orig(url) |
161 | 166 |
except MissingSecret: |
... | ... | |
181 | 186 |
if 'text' not in item: |
182 | 187 |
item['text'] = item['id'] |
183 | 188 |
items.append(item) |
189 |
if hasattr(request, 'datasources_cache'): |
|
190 |
request.datasources_cache[url] = items |
|
184 | 191 |
return items |
185 | 192 |
except qommon.misc.ConnectionError as e: |
186 | 193 |
get_logger().warn('Error loading JSON data source (%s)' % str(e)) |
wcs/qommon/http_request.py | ||
---|---|---|
36 | 36 |
self.is_json_marker = None |
37 | 37 |
self.ignore_session = False |
38 | 38 |
self.wscalls_cache = {} |
39 |
self.datasources_cache = {} |
|
39 | 40 |
# keep a copy of environment to make sure it's not reused along |
40 | 41 |
# uwsgi/gunicorn processes. |
41 | 42 |
self.environ = copy.copy(self.environ) |
42 |
- |