changeset 1492:6ec2741b7268

plugin groupblog: item access availability on serveur is checked on profile connection, and getFeatures is filled accordingly (with "available" key)
author Goffi <goffi@goffi.org>
date Tue, 25 Aug 2015 16:51:00 +0200
parents 704ca56f5ca9
children 1285c714a6cc
files src/plugins/plugin_misc_groupblog.py
diffstat 1 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/plugin_misc_groupblog.py	Tue Aug 25 16:05:01 2015 +0200
+++ b/src/plugins/plugin_misc_groupblog.py	Tue Aug 25 16:51:00 2015 +0200
@@ -145,14 +145,14 @@
     @defer.inlineCallbacks
     def profileConnected(self, profile):
         client = self.host.getClient(profile)
-        groupblog_services = yield self.host.findFeaturesSet((NS_PUBSUB_GROUPBLOG, NS_PUBSUB_AUTO_CREATE), "pubsub", "service", profile_key=profile)
-        if groupblog_services:
-            # we use one of the found services as our default pubsub service
-            client.groupblog_service = groupblog_services.pop()
-            log.info(_(u"item-access powered pubsub service found: {}").format(client.groupblog_service.full()))
+        try:
+            yield self.host.checkFeatures((NS_PUBSUB_GROUPBLOG, NS_PUBSUB_AUTO_CREATE), profile_key=profile)
+        except exceptions.FeatureNotFound:
+            client.server_groupblog_available = False
+            log.warning(_(u"Server is not able to manage item-access pubsub, we can't use group blog"))
         else:
-            client.groupblog_service = None
-            log.warning(_(u"No item-access powered pubsub server found, can't use group blog"))
+            client.server_groupblog_available = True
+            log.info(_(u"Server can manage group blogs"))
 
     def getFeatures(self, profile):
         try:
@@ -160,7 +160,7 @@
         except exceptions.ProfileNotSetError:
             return {}
         try:
-            return {'service': client.groupblog_service.full() if client.groupblog_service is not None else  ''}
+            return {'available': C.boolConst(client.server_groupblog_available)}
         except AttributeError:
             if self.host.isConnected(profile):
                 log.debug("Profile is not connected, service is not checked yet")