comparison src/plugins/plugin_xep_0060.py @ 993:301b342c697a

core: use of the new core.log module: /!\ this is a massive refactoring and was largely automated, it probably did bring some bugs /!\
author Goffi <goffi@goffi.org>
date Sat, 19 Apr 2014 19:19:19 +0200
parents 1a759096ccbd
children 318eab3f93f8
comparison
equal deleted inserted replaced
992:f51a1895275c 993:301b342c697a
17 # You should have received a copy of the GNU Affero General Public License 17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20 from sat.core.i18n import _ 20 from sat.core.i18n import _
21 from sat.core.constants import Const as C 21 from sat.core.constants import Const as C
22 from logging import debug, info, error 22 from sat.core.log import getLogger
23 log = getLogger(__name__)
23 from wokkel.pubsub import PubSubRequest 24 from wokkel.pubsub import PubSubRequest
24 from wokkel import disco, pubsub 25 from wokkel import disco, pubsub
25 from zope.interface import implements 26 from zope.interface import implements
26 27
27 PLUGIN_INFO = { 28 PLUGIN_INFO = {
47 OPT_SUBSCRIPTION_DEPTH = 'pubsub#subscription_depth' 48 OPT_SUBSCRIPTION_DEPTH = 'pubsub#subscription_depth'
48 OPT_ROSTER_GROUPS_ALLOWED = 'pubsub#roster_groups_allowed' 49 OPT_ROSTER_GROUPS_ALLOWED = 'pubsub#roster_groups_allowed'
49 OPT_PUBLISH_MODEL = 'pubsub#publish_model' 50 OPT_PUBLISH_MODEL = 'pubsub#publish_model'
50 51
51 def __init__(self, host): 52 def __init__(self, host):
52 info(_("PubSub plugin initialization")) 53 log.info(_("PubSub plugin initialization"))
53 self.host = host 54 self.host = host
54 self.managedNodes = [] 55 self.managedNodes = []
55 self.clients = {} 56 self.clients = {}
56 """host.bridge.addMethod("getItems", ".plugin", in_sign='ssa{ss}s', out_sign='as', method=self.getItems, 57 """host.bridge.addMethod("getItems", ".plugin", in_sign='ssa{ss}s', out_sign='as', method=self.getItems,
57 async = True, 58 async = True,
84 profile = self.host.memory.getProfileName(profile_key) 85 profile = self.host.memory.getProfileName(profile_key)
85 if not profile: 86 if not profile:
86 err_mess = _('Trying to %(action)s with an unknown profile key [%(profile_key)s]') % { 87 err_mess = _('Trying to %(action)s with an unknown profile key [%(profile_key)s]') % {
87 'action': action, 88 'action': action,
88 'profile_key': profile_key} 89 'profile_key': profile_key}
89 error(err_mess) 90 log.error(err_mess)
90 raise Exception(err_mess) 91 raise Exception(err_mess)
91 try: 92 try:
92 client = self.clients[profile] 93 client = self.clients[profile]
93 except KeyError: 94 except KeyError:
94 err_mess = _('INTERNAL ERROR: no handler for required profile') 95 err_mess = _('INTERNAL ERROR: no handler for required profile')
95 error(err_mess) 96 log.error(err_mess)
96 raise Exception(err_mess) 97 raise Exception(err_mess)
97 return profile, client 98 return profile, client
98 99
99 def publish(self, service, nodeIdentifier, items=None, profile_key=C.PROF_KEY_NONE): 100 def publish(self, service, nodeIdentifier, items=None, profile_key=C.PROF_KEY_NONE):
100 profile, client = self.__getClientNProfile(profile_key, 'publish item') 101 profile, client = self.__getClientNProfile(profile_key, 'publish item')
213 if event.nodeIdentifier == node[0]: 214 if event.nodeIdentifier == node[0]:
214 node[1](event, self.parent.profile) 215 node[1](event, self.parent.profile)
215 216
216 def deleteReceived(self, event): 217 def deleteReceived(self, event):
217 #TODO: manage delete event 218 #TODO: manage delete event
218 debug(_("Publish node deleted")) 219 log.debug(_("Publish node deleted"))
219 220
220 # def purgeReceived(self, event): 221 # def purgeReceived(self, event):
221 222
222 223
223 224