allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kentontay...@apache.org
Subject allura git commit: [#8169] skip last_updated in addition to mod_date fields, when saving markdown cache
Date Mon, 13 Nov 2017 15:21:23 GMT
Repository: allura
Updated Branches:
  refs/heads/master 84c249f0b -> 320cd8184


[#8169] skip last_updated in addition to mod_date fields, when saving markdown cache


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/320cd818
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/320cd818
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/320cd818

Branch: refs/heads/master
Commit: 320cd8184071d19526bd056ab1d426174aad8811
Parents: 84c249f
Author: Dave Brondsema <dave@brondsema.net>
Authored: Thu Nov 9 13:02:42 2017 -0500
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Thu Nov 9 13:02:42 2017 -0500

----------------------------------------------------------------------
 Allura/allura/lib/app_globals.py |  9 +++++----
 Allura/allura/lib/utils.py       | 10 ++++++++++
 2 files changed, 15 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/320cd818/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 1f49315..7397638 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -38,11 +38,12 @@ import pygments
 import pygments.lexers
 import pygments.formatters
 import pygments.util
-from tg import config, session
+from tg import config
 from pylons import request
 from pylons import tmpl_context as c
 from paste.deploy.converters import asbool, asint, aslist
 from pypeline.markup import markup as pypeline_markup
+from ming.odm import session
 
 import ew as ew_core
 import ew.jinja2_ew as ew
@@ -133,9 +134,9 @@ class ForgeMarkdown(markdown.Markdown):
             cache.md5, cache.html, cache.render_time = md5, html, render_time
             cache.fix7528 = bugfix_rev  # flag to indicate good caches created after [#7528]
and other critical bugs were fixed.
 
-            # Prevent cache creation from updating the mod_date timestamp.
-            _session = artifact_orm_session._get()
-            _session.skip_mod_date = True
+            with utils.skip_mod_date(artifact.__class__), \
+                 utils.skip_last_updated(artifact.__class__):
+                session(artifact).flush(artifact)
         return html
 
 

http://git-wip-us.apache.org/repos/asf/allura/blob/320cd818/Allura/allura/lib/utils.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/utils.py b/Allura/allura/lib/utils.py
index 19d677a..08b2695 100644
--- a/Allura/allura/lib/utils.py
+++ b/Allura/allura/lib/utils.py
@@ -692,6 +692,16 @@ def skip_mod_date(model_cls):
         session(model_cls)._get().skip_mod_date = skip_mod_date
 
 
+@contextmanager
+def skip_last_updated(model_cls):
+    skip_last_updated = getattr(session(model_cls)._get(), 'skip_last_updated', False)
+    session(model_cls)._get().skip_last_updated = True
+    try:
+        yield
+    finally:
+        session(model_cls)._get().skip_last_updated = skip_last_updated
+
+
 def unique_attachments(attachments):
     """Given a list of :class:`allura.model.attachments.BaseAttachment` return
     a list where each filename present only once. If original list contains


Mime
View raw message