Commits

Alessandro Molina committed 26994e7

Fix issue with caching articles

Comments (0)

Files changed (2)

 
 setup(
     name='tgapp-smallpress',
-    version='0.2',
+    version='0.2.1',
     description='Pluggable Minimalistic Blog for TurboGears2 with Attachments and Tags',
     long_description=README,
     author='Alessandro Molina',

smallpress/partials.py

-from tg import expose
+from tg import expose, request
 from model import Article, Tagging
-from tgext.pluggable import plug_url
+from tgext.pluggable import plug_url, primary_key, app_model
 from tgext.tagging import TagCloud
 from smallpress.lib.forms import SearchForm
 
 
 @expose('genshi:smallpress.templates.article_preview')
 def article_preview(article):
-    return dict(article=article, tg_cache=dict(key='%s-%s' % (article.uid,
-                                                              article.update_date.strftime('%Y-%m-%d_%H:%M:%S')),
+    user = 'anonymous'
+    if request.identity:
+        user = getattr(request.identity['user'], primary_key(app_model.User).key)
+    return dict(article=article, tg_cache=dict(key='%s-%s-%s' % (article.uid, user,
+                                                                 article.update_date.strftime('%Y-%m-%d_%H:%M:%S')),
                                                expire=None,
                                                type='memory'))