Mercurial > libervia-backend
diff sat/plugins/plugin_misc_groupblog.py @ 2807:0b7ce5daee9b
plugin XEP-0277: blog items data are now entirely serialised before going to bridge:
So far, and for historical reasons, blog items data where serialised using a unicode: unicode dict, which was causing trouble for many types of values (timestamps, booleans, lists).
This patch changes it by serialising the whole items before going to bridge, and deserialising it when going back. This way, complex data can be used easily in items.
This impact psEvent and serItemsData* methods which are renamed transItemsData* because there are not always serialising anymore (a new argument "serialise" allows to specify it).
When editing a blog post in jp, metadata are now more easy to manipulate, specially lists like tags.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 23 Feb 2019 18:59:00 +0100 |
parents | 003b8b4b56a7 |
children | ab2696e34d29 |
line wrap: on
line diff
--- a/sat/plugins/plugin_misc_groupblog.py Wed Feb 20 19:42:35 2019 +0100 +++ b/sat/plugins/plugin_misc_groupblog.py Sat Feb 23 18:59:00 2019 +0100 @@ -26,7 +26,6 @@ from sat.core import exceptions from wokkel import disco, data_form, iwokkel from zope.interface import implements -from sat.tools.common import data_format try: from twisted.words.protocols.xmlstream import XMPPHandler @@ -107,11 +106,8 @@ return access_model = config_form.get(self._p.OPT_ACCESS_MODEL, self._p.ACCESS_OPEN) if access_model == self._p.ACCESS_PUBLISHER_ROSTER: - data_format.iter2dict( - "group", - config_form.fields[self._p.OPT_ROSTER_GROUPS_ALLOWED].values, - microblog_data, - ) + opt = self._p.OPT_ROSTER_GROUPS_ALLOWED + microblog_data['groups'] = config_form.fields[opt].values def _data2entryTrigger(self, client, mb_data, entry_elt, item_elt): """Build fine access permission if needed @@ -119,7 +115,7 @@ This trigger check if "group*" key are present, and create a fine item config to restrict view to these groups """ - groups = list(data_format.dict2iter("group", mb_data)) + groups = mb_data.get('groups', []) if not groups: return if not client.server_groupblog_available: @@ -141,10 +137,7 @@ """ if "group" in mb_data: options[self._p.OPT_ACCESS_MODEL] = self._p.ACCESS_PUBLISHER_ROSTER - options[self._p.OPT_ROSTER_GROUPS_ALLOWED] = list( - data_format.dict2iter("group", mb_data) - ) - + options[self._p.OPT_ROSTER_GROUPS_ALLOWED] = mb_data['groups'] class GroupBlog_handler(XMPPHandler): implements(iwokkel.IDisco)