]> git.ipfire.org Git - ipfire.org.git/commitdiff
blog: Use caching in backend
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 11 Oct 2018 12:15:25 +0000 (13:15 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 11 Oct 2018 12:15:25 +0000 (13:15 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/blog.py

index f8d6144acd1e418cf8ba64f281eab41084d5a1cd..2bc51ea1702557a02c768f577c4c27ce5938988f 100644 (file)
@@ -8,6 +8,7 @@ import textile
 import unicodedata
 
 from . import misc
+from .decorators import *
 
 # Used to automatically link some things
 link_patterns = (
@@ -228,8 +229,7 @@ class Post(misc.Object):
        def slug(self):
                return self.data.slug
 
-       # XXX needs caching
-       @property
+       @lazy_property
        def author(self):
                if self.data.author_uid:
                        return self.backend.accounts.get_by_uid(self.data.author_uid)
@@ -280,7 +280,7 @@ class Post(misc.Object):
 
        # HTML
 
-       @property
+       @lazy_property
        def html(self):
                """
                        Returns this post as rendered HTML
@@ -299,8 +299,7 @@ class Post(misc.Object):
        def link(self):
                return self.data.link
 
-       # XXX needs caching
-       @property
+       @lazy_property
        def release(self):
                return self.backend.releases._get_release("SELECT * FROM releases \
                        WHERE published IS NOT NULL AND published <= NOW() AND blog_id = %s", self.id)