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.
This commit is contained in:
parent
c89a771c06
commit
512ae0b91e
1 changed files with 188 additions and 184 deletions
|
|
@ -26,7 +26,6 @@ from twisted.internet import defer
|
|||
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 @@ class GroupBlog(object):
|
|||
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 @@ class GroupBlog(object):
|
|||
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 @@ class GroupBlog(object):
|
|||
"""
|
||||
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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue