comparison sat_frontends/quick_frontend/quick_app.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 441b536e28ed
children 649cb3fd7711
comparison
equal deleted inserted replaced
2806:2400cad2dace 2807:0b7ce5daee9b
986 986
987 @param category(unicode): event category (e.g. "PEP", "MICROBLOG") 987 @param category(unicode): event category (e.g. "PEP", "MICROBLOG")
988 @param service_s (unicode): pubsub service 988 @param service_s (unicode): pubsub service
989 @param node (unicode): pubsub node 989 @param node (unicode): pubsub node
990 @param event_type (unicode): event type (one of C.PUBLISH, C.RETRACT, C.DELETE) 990 @param event_type (unicode): event type (one of C.PUBLISH, C.RETRACT, C.DELETE)
991 @param data (dict): event data 991 @param data (serialised_dict): event data
992 """ 992 """
993 data = data_format.deserialise(data)
993 service_s = jid.JID(service_s) 994 service_s = jid.JID(service_s)
994 995
995 if category == C.PS_MICROBLOG and self.MB_HANDLER: 996 if category == C.PS_MICROBLOG and self.MB_HANDLER:
996 if event_type == C.PS_PUBLISH: 997 if event_type == C.PS_PUBLISH:
997 if not "content" in data: 998 if not "content" in data:
998 log.warning("No content found in microblog data") 999 log.warning("No content found in microblog data")
999 return 1000 return
1000 _groups = ( 1001
1001 set(data_format.dict2iter("group", data)) or None 1002 # FIXME: check if [] make sense (instead of None)
1002 ) # FIXME: check if [] make sense (instead of None) 1003 _groups = data.get("group")
1003 1004
1004 for wid in self.widgets.getWidgets(quick_blog.QuickBlog): 1005 for wid in self.widgets.getWidgets(quick_blog.QuickBlog):
1005 wid.addEntryIfAccepted(service_s, node, data, _groups, profile) 1006 wid.addEntryIfAccepted(service_s, node, data, _groups, profile)
1006 1007
1007 try: 1008 try: