plugin groupblog: item access availability on serveur is checked on profile connection, and getFeatures is filled accordingly (with "available" key)

This commit is contained in:
Goffi 2015-08-25 16:51:00 +02:00
commit 11acf009ee

View file

@ -145,14 +145,14 @@ class GroupBlog(object):
@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 @@ class GroupBlog(object):
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")