diff src/plugins/plugin_misc_groupblog.py @ 916:1a759096ccbd

core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
author Goffi <goffi@goffi.org>
date Fri, 21 Mar 2014 16:27:09 +0100
parents 58107179cd97
children fc7e0828b18e
line wrap: on
line diff
--- a/src/plugins/plugin_misc_groupblog.py	Fri Mar 21 16:19:46 2014 +0100
+++ b/src/plugins/plugin_misc_groupblog.py	Fri Mar 21 16:27:09 2014 +0100
@@ -18,6 +18,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from sat.core.i18n import _
+from sat.core.constants import Const as C
 from logging import debug, info, warning, error
 from twisted.internet import defer
 from twisted.words.protocols.jabber import jid
@@ -357,7 +358,7 @@
         #TODO
         return failure
 
-    def sendGroupBlog(self, access_type, access_list, message, extra, profile_key='@NONE@'):
+    def sendGroupBlog(self, access_type, access_list, message, extra, profile_key=C.PROF_KEY_NONE):
         """Publish a microblog with given item access
         @param access_type: one of "PUBLIC", "GROUP", "JID"
         @param access_list: list of authorized entity (empty list for PUBLIC ACCESS,
@@ -388,7 +389,7 @@
 
         return self._initialise(profile_key).addCallback(initialised)
 
-    def deleteGroupBlog(self, pub_data, comments, profile_key='@NONE@'):
+    def deleteGroupBlog(self, pub_data, comments, profile_key=C.PROF_KEY_NONE):
         """Delete a microblog item from a node.
         @param pub_data: a tuple (service, node identifier, item identifier)
         @param comments: comments node identifier (for main item) or empty string
@@ -425,7 +426,7 @@
 
         return self._initialise(profile_key).addCallback(initialised).addCallback(notify)
 
-    def updateGroupBlog(self, pub_data, comments, message, extra, profile_key='@NONE@'):
+    def updateGroupBlog(self, pub_data, comments, message, extra, profile_key=C.PROF_KEY_NONE):
         """Modify a microblog node
         @param pub_data: a tuple (service, node identifier, item identifier)
         @param comments: comments node identifier (for main item) or empty string
@@ -462,7 +463,7 @@
 
         return self._initialise(profile_key).addCallback(initialised)
 
-    def sendGroupBlogComment(self, node_url, message, extra, profile_key='@NONE@'):
+    def sendGroupBlogComment(self, node_url, message, extra, profile_key=C.PROF_KEY_NONE):
         """Publish a comment in the given node
         @param node url: link to the comments node as specified in XEP-0277 and given in microblog data's comments key
         @param message: comment
@@ -514,7 +515,7 @@
                     warning("Missing key for comments")
         defer.returnValue(ret)
 
-    def __getGroupBlogs(self, pub_jid_s, max_items=10, item_ids=None, profile_key='@NONE@'):
+    def __getGroupBlogs(self, pub_jid_s, max_items=10, item_ids=None, profile_key=C.PROF_KEY_NONE):
         """Retrieve previously published items from a publish subscribe node.
         @param pub_jid_s: jid of the publisher
         @param max_items: how many microblogs we want to get (see XEP-0060 #6.5.7)
@@ -535,7 +536,7 @@
         #TODO: we need to use the server corresponding the the host of the jid
         return self._initialise(profile_key).addCallback(initialised)
 
-    def getGroupBlogs(self, pub_jid_s, item_ids=None, profile_key='@NONE@'):
+    def getGroupBlogs(self, pub_jid_s, item_ids=None, profile_key=C.PROF_KEY_NONE):
         """Get the published microblogs of the specified IDs. If item_ids is
         None, the result would be the same than calling getLastGroupBlogs
         with the default value for the attribute max_items.
@@ -546,7 +547,7 @@
         """
         return self.__getGroupBlogs(pub_jid_s, item_ids=item_ids, profile_key=profile_key)
 
-    def getGroupBlogsWithComments(self, pub_jid_s, item_ids=None, profile_key='@NONE@'):
+    def getGroupBlogsWithComments(self, pub_jid_s, item_ids=None, profile_key=C.PROF_KEY_NONE):
         """Get the published microblogs of the specified IDs and their comments. If
         item_ids is None, returns the last published microblogs and their comments.
         @param pub_jid_s: jid of the publisher
@@ -572,7 +573,7 @@
         return d
 
 
-    def getLastGroupBlogs(self, pub_jid_s, max_items=10, profile_key='@NONE@'):
+    def getLastGroupBlogs(self, pub_jid_s, max_items=10, profile_key=C.PROF_KEY_NONE):
         """Get the last published microblogs
         @param pub_jid_s: jid of the publisher
         @param max_items: how many microblogs we want to get (see XEP-0060 #6.5.7)
@@ -581,7 +582,7 @@
         """
         return self.__getGroupBlogs(pub_jid_s, max_items=max_items, profile_key=profile_key)
 
-    def getLastGroupBlogsAtom(self, pub_jid_s, max_items=10, profile_key='@NONE@'):
+    def getLastGroupBlogsAtom(self, pub_jid_s, max_items=10, profile_key=C.PROF_KEY_NONE):
         """Get the atom feed of the last published microblogs
         @param pub_jid: jid of the publisher
         @param max_items: how many microblogs we want to get (see XEP-0060 #6.5.7)
@@ -628,7 +629,7 @@
         #TODO: we need to use the server corresponding the the host of the jid
         return self._initialise(profile_key).addCallback(initialised)
 
-    def getGroupBlogComments(self, service_s, node, profile_key='@NONE@'):
+    def getGroupBlogComments(self, service_s, node, profile_key=C.PROF_KEY_NONE):
         """Get all comments of given node
         @param service_s: service hosting the node
         @param node: comments node
@@ -648,14 +649,14 @@
         #TODO: we need to use the server corresponding the the host of the jid
         return self._initialise(profile_key).addCallback(initialised)
 
-    def _getMassiveLastGroupBlogs(self, publishers_type, publishers, max_items=10, profile_key='@NONE@'):
+    def _getMassiveLastGroupBlogs(self, publishers_type, publishers, max_items=10, profile_key=C.PROF_KEY_NONE):
         if publishers_type == 'JID':
             publishers_jids = [jid.JID(publisher) for publisher in publishers]
         else:
             publishers_jids = publishers
         return self.getMassiveLastGroupBlogs(publishers_type, publishers_jids, max_items, profile_key)
 
-    def getMassiveLastGroupBlogs(self, publishers_type, publishers, max_items=10, profile_key='@NONE@'):
+    def getMassiveLastGroupBlogs(self, publishers_type, publishers, max_items=10, profile_key=C.PROF_KEY_NONE):
         """Get the last published microblogs for a list of groups or jids
         @param publishers_type: type of the list of publishers (one of "GROUP" or "JID" or "ALL")
         @param publishers: list of publishers, according to "publishers_type" (list of groups or list of jids)
@@ -715,7 +716,7 @@
         return self._initialise(profile_key).addCallback(initialised)
         #TODO: we need to use the server corresponding the the host of the jid
 
-    def subscribeGroupBlog(self, pub_jid, profile_key='@NONE@'):
+    def subscribeGroupBlog(self, pub_jid, profile_key=C.PROF_KEY_NONE):
         def initialised(result):
             profile, client = result
             d = self.host.plugins["XEP-0060"].subscribe(client.item_access_pubsub, self.getNodeName(jid.JID(pub_jid)),
@@ -725,14 +726,14 @@
         #TODO: we need to use the server corresponding the the host of the jid
         return self._initialise(profile_key).addCallback(initialised)
 
-    def _massiveSubscribeGroupBlogs(self, publishers_type, publishers, profile_key='@NONE@'):
+    def _massiveSubscribeGroupBlogs(self, publishers_type, publishers, profile_key=C.PROF_KEY_NONE):
         if publishers_type == 'JID':
             publishers_jids = [jid.JID(publisher) for publisher in publishers]
         else:
             publishers_jids = publishers
         return self.massiveSubscribeGroupBlogs(publishers_type, publishers_jids, profile_key)
 
-    def massiveSubscribeGroupBlogs(self, publishers_type, publishers, profile_key='@NONE@'):
+    def massiveSubscribeGroupBlogs(self, publishers_type, publishers, profile_key=C.PROF_KEY_NONE):
         """Subscribe microblogs for a list of groups or jids
         @param publishers_type: type of the list of publishers (one of "GROUP" or "JID" or "ALL")
         @param publishers: list of publishers, according to "publishers_type" (list of groups or list of jids)