comparison src/plugins/plugin_misc_groupblog.py @ 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 9fcc16ef163a
children afa0894dcc71
comparison
equal deleted inserted replaced
1491:704ca56f5ca9 1492:6ec2741b7268
143 return GroupBlog_handler() 143 return GroupBlog_handler()
144 144
145 @defer.inlineCallbacks 145 @defer.inlineCallbacks
146 def profileConnected(self, profile): 146 def profileConnected(self, profile):
147 client = self.host.getClient(profile) 147 client = self.host.getClient(profile)
148 groupblog_services = yield self.host.findFeaturesSet((NS_PUBSUB_GROUPBLOG, NS_PUBSUB_AUTO_CREATE), "pubsub", "service", profile_key=profile) 148 try:
149 if groupblog_services: 149 yield self.host.checkFeatures((NS_PUBSUB_GROUPBLOG, NS_PUBSUB_AUTO_CREATE), profile_key=profile)
150 # we use one of the found services as our default pubsub service 150 except exceptions.FeatureNotFound:
151 client.groupblog_service = groupblog_services.pop() 151 client.server_groupblog_available = False
152 log.info(_(u"item-access powered pubsub service found: {}").format(client.groupblog_service.full())) 152 log.warning(_(u"Server is not able to manage item-access pubsub, we can't use group blog"))
153 else: 153 else:
154 client.groupblog_service = None 154 client.server_groupblog_available = True
155 log.warning(_(u"No item-access powered pubsub server found, can't use group blog")) 155 log.info(_(u"Server can manage group blogs"))
156 156
157 def getFeatures(self, profile): 157 def getFeatures(self, profile):
158 try: 158 try:
159 client = self.host.getClient(profile) 159 client = self.host.getClient(profile)
160 except exceptions.ProfileNotSetError: 160 except exceptions.ProfileNotSetError:
161 return {} 161 return {}
162 try: 162 try:
163 return {'service': client.groupblog_service.full() if client.groupblog_service is not None else ''} 163 return {'available': C.boolConst(client.server_groupblog_available)}
164 except AttributeError: 164 except AttributeError:
165 if self.host.isConnected(profile): 165 if self.host.isConnected(profile):
166 log.debug("Profile is not connected, service is not checked yet") 166 log.debug("Profile is not connected, service is not checked yet")
167 else: 167 else:
168 log.error("Service should be available !") 168 log.error("Service should be available !")