Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0048.py @ 989:93359853e4bc
plugins XEP-0048, XEP-0049: feature is not checked anymore before using private XML storage, as feature announcement is not mandatory in XEP-0049
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 10 Apr 2014 16:12:50 +0200 |
parents | 224cafc67324 |
children | 301b342c697a |
comparison
equal
deleted
inserted
replaced
988:b3076b5797f6 | 989:93359853e4bc |
---|---|
23 from sat.memory.persistent import PersistentBinaryDict | 23 from sat.memory.persistent import PersistentBinaryDict |
24 from sat.tools import xml_tools | 24 from sat.tools import xml_tools |
25 from logging import debug, info, warning, error | 25 from logging import debug, info, warning, error |
26 from twisted.words.xish import domish | 26 from twisted.words.xish import domish |
27 from twisted.words.protocols.jabber import jid | 27 from twisted.words.protocols.jabber import jid |
28 from twisted.words.protocols.jabber.error import StanzaError | |
28 | 29 |
29 from twisted.internet import defer | 30 from twisted.internet import defer |
30 | 31 |
31 NS_BOOKMARKS = 'storage:bookmarks' | 32 NS_BOOKMARKS = 'storage:bookmarks' |
32 | 33 |
96 @param storage_type: storage type, can be: | 97 @param storage_type: storage type, can be: |
97 - 'private': XEP-0049 storage | 98 - 'private': XEP-0049 storage |
98 - 'pubsub': XEP-0223 storage | 99 - 'pubsub': XEP-0223 storage |
99 @param profile: %(doc_profile)s | 100 @param profile: %(doc_profile)s |
100 @return: data dictionary, or None if feature is not available | 101 @return: data dictionary, or None if feature is not available |
101 | |
102 @raise: exception.FeatureNotFound | |
103 """ | 102 """ |
104 client = self.host.getClient(profile) | 103 client = self.host.getClient(profile) |
105 if storage_type == 'private': | 104 if storage_type == 'private': |
106 try: | 105 try: |
107 bookmarks_private_xml = yield self.private_plg.privateXMLGet('storage', NS_BOOKMARKS, profile) | 106 bookmarks_private_xml = yield self.private_plg.privateXMLGet('storage', NS_BOOKMARKS, profile) |
108 data = client.bookmarks_private = self._bookmarkElt2Dict(bookmarks_private_xml) | 107 data = client.bookmarks_private = self._bookmarkElt2Dict(bookmarks_private_xml) |
109 except (exceptions.FeatureNotFound, AttributeError): | 108 except (StanzaError, AttributeError): |
110 info(_("Private XML storage not available")) | 109 info(_("Private XML storage not available")) |
111 data = client.bookmarks_private = None | 110 data = client.bookmarks_private = None |
112 elif storage_type == 'pubsub': | 111 elif storage_type == 'pubsub': |
113 raise NotImplementedError | 112 raise NotImplementedError |
114 else: | 113 else: |