diff libervia.tac @ 282:ae3ec654836d

browser_side: added blog item modification/deletion
author souliane <souliane@mailoo.org>
date Tue, 10 Dec 2013 09:07:03 +0100
parents 2d6bd975a72d
children 33e0eb212b14
line wrap: on
line diff
--- a/libervia.tac	Mon Dec 09 15:34:03 2013 +0100
+++ b/libervia.tac	Tue Dec 10 09:07:03 2013 +0100
@@ -41,7 +41,7 @@
 from server_side.blog import MicroBlog
 from zope.interface import Interface, Attribute, implements
 from xml.dom import minidom
-
+from sat_frontends.constants import Const
 
 #import time
 
@@ -251,6 +251,28 @@
         else:
             raise Exception("Invalid data")
 
+    def jsonrpc_deleteMblog(self, pub_data, comments):
+        """Delete a microblog node
+        @param pub_data: a tuple (service, comment node identifier, item identifier)
+        @param comments: comments node identifier (for main item) or False
+        """
+        profile = ISATSession(self.session).profile
+        return self.sat_host.bridge.deleteGroupBlog(pub_data, comments if comments else '', profile)
+
+    def jsonrpc_updateMblog(self, pub_data, comments, message, extra={}):
+        """Modify a microblog node
+        @param pub_data: a tuple (service, comment node identifier, item identifier)
+        @param comments: comments node identifier (for main item) or False
+        @param message: new message
+        @param extra: dict which option name as key, which can be:
+            - allow_comments: True to accept an other level of comments, False else (default: False)
+            - rich: if present, contain rich text in currently selected syntax
+        """
+        profile = ISATSession(self.session).profile
+        if comments:
+            extra['allow_comments'] = 'True'
+        return self.sat_host.bridge.updateGroupBlog(pub_data, comments if comments else '', message, extra, profile)
+
     def jsonrpc_sendMblogComment(self, node, text, extra={}):
         """ Send microblog message
         @param node: url of the comments node
@@ -482,6 +504,16 @@
         profile = ISATSession(self.session).profile
         self.sat_host.bridge.confirmationAnswer(confirmation_id, result, answer_data, profile)
 
+    def jsonrpc_syntaxConvert(self, text, syntax_from=Const._SYNTAX_XHTML, syntax_to=Const._SYNTAX_CURRENT):
+        """ Convert a text between two syntaxes
+        @param text: text to convert
+        @param syntax_from: source syntax (e.g. "markdown")
+        @param syntax_to: dest syntax (e.g.: "XHTML")
+        @param safe: clean resulting XHTML to avoid malicious code if True (forced here)
+        @return: converted text """
+        profile = ISATSession(self.session).profile
+        return self.sat_host.bridge.syntaxConvert(text, syntax_from, syntax_to, True, profile)
+
 
 class Register(JSONRPCMethodManager):
     """This class manage the registration procedure with SàT