You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2015/04/21 16:25:45 UTC
[15/25] allura git commit: [#7852] Fixed an issue where 'mod_time'
was getting updated on the first view.
[#7852] Fixed an issue where 'mod_time' was getting updated on the first view.
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/b5b01d01
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/b5b01d01
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/b5b01d01
Branch: refs/heads/ib/7856
Commit: b5b01d01f8d9d3cc25e0e0681480e5fc3b2b1a07
Parents: ad7c5f9
Author: Heith Seewald <hs...@slashdotmedia.com>
Authored: Tue Apr 14 13:29:20 2015 -0400
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Thu Apr 16 13:04:18 2015 -0400
----------------------------------------------------------------------
Allura/allura/lib/app_globals.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/b5b01d01/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 30bfbf3..31f3c79 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -63,6 +63,7 @@ from allura.lib.widgets import analytics
from allura.lib.security import Credentials
from allura.lib.solr import MockSOLR, make_solr_from_config
from allura.lib.zarkov_helpers import ZarkovClient
+from allura.model.session import artifact_orm_session
log = logging.getLogger(__name__)
@@ -104,11 +105,13 @@ class ForgeMarkdown(markdown.Markdown):
return self.convert(source_text)
md5 = None
+ # If a cached version exists and it is valid, return it.
if cache.md5 is not None:
md5 = hashlib.md5(source_text.encode('utf-8')).hexdigest()
if cache.md5 == md5 and getattr(cache, 'fix7528', False):
return h.html.literal(cache.html)
+ # Convert the markdown and time the result.
start = time.time()
html = self.convert(source_text)
render_time = time.time() - start
@@ -121,11 +124,16 @@ class ForgeMarkdown(markdown.Markdown):
log.warn('Skipping Markdown caching - The value for config param '
'"markdown_cache_threshold" must be a float.')
- if threshold != None and render_time > threshold:
+ if threshold is not None and render_time > threshold:
+ # Save the cache
if md5 is None:
md5 = hashlib.md5(source_text.encode('utf-8')).hexdigest()
cache.md5, cache.html, cache.render_time = md5, html, render_time
cache.fix7528 = True # flag to indicate good caches created after [#7528] was fixed
+
+ # Prevent cache creation from updating the mod_date timestamp.
+ _session = artifact_orm_session._get()
+ setattr(_session, 'skip_mod_date', True)
return html