Mercurial > libervia-web
changeset 947:92f0eeb6dc72
pages: cache identities identities in session + get identities for comments in blog
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 23 May 2017 00:06:00 +0200 |
parents | d076b722ca52 |
children | c20ac29d869f |
files | src/pages/common/blog/page_meta.py src/server/session_iface.py |
diffstat | 2 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/pages/common/blog/page_meta.py Sun May 21 16:00:55 2017 +0200 +++ b/src/pages/common/blog/page_meta.py Tue May 23 00:06:00 2017 +0200 @@ -4,6 +4,7 @@ from twisted.words.protocols.jabber import jid from twisted.internet import defer from sat.tools.common import data_objects +from libervia.server import session_iface from sat.core.i18n import _ from sat.core.log import getLogger import urllib @@ -47,8 +48,12 @@ @defer.inlineCallbacks -def appendComments(self, blog_items, profile): +def appendComments(self, blog_items, identities, profile): for blog_item in blog_items: + if identities is not None: + author = blog_item.author_jid + if author not in identities: + identities[author] = yield self.host.bridge.identityGet(author, profile) for comment_data in blog_item.comments: service = comment_data[u'service'] node = comment_data[u'node'] @@ -61,7 +66,7 @@ profile) comments = data_objects.BlogItems(comments_data) blog_item.appendCommentsItems(comments) - yield appendComments(self, comments, profile) + yield appendComments(self, comments, identities, profile) @defer.inlineCallbacks @@ -89,11 +94,12 @@ raise e items = data_objects.BlogItems(blog_data) + template_data = request.template_data + identities = template_data[u'identities'] = self.host.getSessionData(request, session_iface.ISATSession).identities if show_comments: - yield appendComments(self, items, profile) + yield appendComments(self, items, identities, profile) - template_data = request.template_data template_data[u'items'] = items template_data[u'allow_commenting'] = u'simple'
--- a/src/server/session_iface.py Sun May 21 16:00:55 2017 +0200 +++ b/src/server/session_iface.py Tue May 23 00:06:00 2017 +0200 @@ -17,12 +17,14 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from zope.interface import Interface, Attribute, implements +from sat.tools.common import data_objects import shortuuid class ISATSession(Interface): profile = Attribute("Sat profile") jid = Attribute("JID associated with the profile") uuid = Attribute("uuid associated with the profile session") + identities = Attribute("Identities of XMPP entities") class SATSession(object): @@ -32,6 +34,7 @@ self.profile = None self.jid = None self.uuid = unicode(shortuuid.uuid()) + self.identities = data_objects.Identities() class ISATGuestSession(Interface):