Mercurial > libervia-backend
comparison frontends/src/quick_frontend/quick_blog.py @ 1919:d3354c80bd1f
core (tools): moved common to a separate package, and put data method in a data_format module
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 22 Mar 2016 22:46:04 +0100 |
parents | a754d6381550 |
children | 2daf7b4c6756 |
comparison
equal
deleted
inserted
replaced
1918:01d56efd488b | 1919:d3354c80bd1f |
---|---|
23 | 23 |
24 | 24 |
25 from sat_frontends.quick_frontend.constants import Const as C | 25 from sat_frontends.quick_frontend.constants import Const as C |
26 from sat_frontends.quick_frontend import quick_widgets | 26 from sat_frontends.quick_frontend import quick_widgets |
27 from sat_frontends.tools import jid | 27 from sat_frontends.tools import jid |
28 from sat.tools import common | 28 from sat.tools.common import data_format |
29 | 29 |
30 try: | 30 try: |
31 # FIXME: to be removed when an acceptable solution is here | 31 # FIXME: to be removed when an acceptable solution is here |
32 unicode('') # XXX: unicode doesn't exist in pyjamas | 32 unicode('') # XXX: unicode doesn't exist in pyjamas |
33 except (TypeError, AttributeError): # Error raised is not the same depending on pyjsbuild options | 33 except (TypeError, AttributeError): # Error raised is not the same depending on pyjsbuild options |
47 """ | 47 """ |
48 self.id = data['id'] | 48 self.id = data['id'] |
49 self.title = data.get('title') | 49 self.title = data.get('title') |
50 self.title_rich = None | 50 self.title_rich = None |
51 self.title_xhtml = data.get('title_xhtml') | 51 self.title_xhtml = data.get('title_xhtml') |
52 self.tags = list(common.dict2iter('tag', data)) | 52 self.tags = list(data_format.dict2iter('tag', data)) |
53 self.content = data.get('content') | 53 self.content = data.get('content') |
54 self.content_rich = None | 54 self.content_rich = None |
55 self.content_xhtml = data.get('content_xhtml') | 55 self.content_xhtml = data.get('content_xhtml') |
56 self.author = data['author'] | 56 self.author = data['author'] |
57 try: | 57 try: |
262 name = '{}{}'.format(prefix, suffix) | 262 name = '{}{}'.format(prefix, suffix) |
263 value = getattr(self.item, name) | 263 value = getattr(self.item, name) |
264 if value is not None: | 264 if value is not None: |
265 mb_data[name] = value | 265 mb_data[name] = value |
266 | 266 |
267 common.iter2dict('tag', self.item.tags, mb_data) | 267 data_format.iter2dict('tag', self.item.tags, mb_data) |
268 | 268 |
269 if self.blog.new_message_target not in (C.PUBLIC, C.GROUP): | 269 if self.blog.new_message_target not in (C.PUBLIC, C.GROUP): |
270 raise NotImplementedError | 270 raise NotImplementedError |
271 | 271 |
272 if self.level == 0: | 272 if self.level == 0: |
273 mb_data["allow_comments"] = C.BOOL_TRUE | 273 mb_data["allow_comments"] = C.BOOL_TRUE |
274 | 274 |
275 if self.blog.new_message_target == C.GROUP: | 275 if self.blog.new_message_target == C.GROUP: |
276 common.iter2dict('group', self.blog.targets, mb_data) | 276 data_format.iter2dict('group', self.blog.targets, mb_data) |
277 | 277 |
278 self.blog.host.bridge.mbSend( | 278 self.blog.host.bridge.mbSend( |
279 unicode(self.service or ''), | 279 unicode(self.service or ''), |
280 self.node or '', | 280 self.node or '', |
281 mb_data, | 281 mb_data, |