Mercurial > libervia-web
comparison 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 |
comparison
equal
deleted
inserted
replaced
281:36ce989c73a5 | 282:ae3ec654836d |
---|---|
39 import os.path, sys | 39 import os.path, sys |
40 import tempfile, shutil, uuid | 40 import tempfile, shutil, uuid |
41 from server_side.blog import MicroBlog | 41 from server_side.blog import MicroBlog |
42 from zope.interface import Interface, Attribute, implements | 42 from zope.interface import Interface, Attribute, implements |
43 from xml.dom import minidom | 43 from xml.dom import minidom |
44 | 44 from sat_frontends.constants import Const |
45 | 45 |
46 #import time | 46 #import time |
47 | 47 |
48 TIMEOUT = 300 #Session's time out, after that the user will be disconnected | 48 TIMEOUT = 300 #Session's time out, after that the user will be disconnected |
49 LIBERVIA_DIR = "output/" | 49 LIBERVIA_DIR = "output/" |
248 else: | 248 else: |
249 print "sending group blog" | 249 print "sending group blog" |
250 return self.sat_host.bridge.sendGroupBlog("GROUP", [dest], text, extra, profile) | 250 return self.sat_host.bridge.sendGroupBlog("GROUP", [dest], text, extra, profile) |
251 else: | 251 else: |
252 raise Exception("Invalid data") | 252 raise Exception("Invalid data") |
253 | |
254 def jsonrpc_deleteMblog(self, pub_data, comments): | |
255 """Delete a microblog node | |
256 @param pub_data: a tuple (service, comment node identifier, item identifier) | |
257 @param comments: comments node identifier (for main item) or False | |
258 """ | |
259 profile = ISATSession(self.session).profile | |
260 return self.sat_host.bridge.deleteGroupBlog(pub_data, comments if comments else '', profile) | |
261 | |
262 def jsonrpc_updateMblog(self, pub_data, comments, message, extra={}): | |
263 """Modify a microblog node | |
264 @param pub_data: a tuple (service, comment node identifier, item identifier) | |
265 @param comments: comments node identifier (for main item) or False | |
266 @param message: new message | |
267 @param extra: dict which option name as key, which can be: | |
268 - allow_comments: True to accept an other level of comments, False else (default: False) | |
269 - rich: if present, contain rich text in currently selected syntax | |
270 """ | |
271 profile = ISATSession(self.session).profile | |
272 if comments: | |
273 extra['allow_comments'] = 'True' | |
274 return self.sat_host.bridge.updateGroupBlog(pub_data, comments if comments else '', message, extra, profile) | |
253 | 275 |
254 def jsonrpc_sendMblogComment(self, node, text, extra={}): | 276 def jsonrpc_sendMblogComment(self, node, text, extra={}): |
255 """ Send microblog message | 277 """ Send microblog message |
256 @param node: url of the comments node | 278 @param node: url of the comments node |
257 @param text: comment | 279 @param text: comment |
479 | 501 |
480 def jsonrpc_confirmationAnswer(self, confirmation_id, result, answer_data): | 502 def jsonrpc_confirmationAnswer(self, confirmation_id, result, answer_data): |
481 """Send the user's answer to any previous 'askConfirmation' signal""" | 503 """Send the user's answer to any previous 'askConfirmation' signal""" |
482 profile = ISATSession(self.session).profile | 504 profile = ISATSession(self.session).profile |
483 self.sat_host.bridge.confirmationAnswer(confirmation_id, result, answer_data, profile) | 505 self.sat_host.bridge.confirmationAnswer(confirmation_id, result, answer_data, profile) |
506 | |
507 def jsonrpc_syntaxConvert(self, text, syntax_from=Const._SYNTAX_XHTML, syntax_to=Const._SYNTAX_CURRENT): | |
508 """ Convert a text between two syntaxes | |
509 @param text: text to convert | |
510 @param syntax_from: source syntax (e.g. "markdown") | |
511 @param syntax_to: dest syntax (e.g.: "XHTML") | |
512 @param safe: clean resulting XHTML to avoid malicious code if True (forced here) | |
513 @return: converted text """ | |
514 profile = ISATSession(self.session).profile | |
515 return self.sat_host.bridge.syntaxConvert(text, syntax_from, syntax_to, True, profile) | |
484 | 516 |
485 | 517 |
486 class Register(JSONRPCMethodManager): | 518 class Register(JSONRPCMethodManager): |
487 """This class manage the registration procedure with SàT | 519 """This class manage the registration procedure with SàT |
488 It provide an api for the browser, check password and setup the web server""" | 520 It provide an api for the browser, check password and setup the web server""" |