# HG changeset patch # User Goffi # Date 1495490760 -7200 # Node ID 92f0eeb6dc72e9a83de3b6a329e909ef8a57ed41 # Parent d076b722ca52b537fe891720b3618b765c88c738 pages: cache identities identities in session + get identities for comments in blog diff -r d076b722ca52 -r 92f0eeb6dc72 src/pages/common/blog/page_meta.py --- 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' diff -r d076b722ca52 -r 92f0eeb6dc72 src/server/session_iface.py --- 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 . 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):