def demarshall(obj, message): types_tool = api.portal.get_tool('portal_types') fti = types_tool.get(obj.portal_type) if IDexterityFTI.providedBy(fti): # DX payload = message._payload message._payload = None initializeObjectFromSchemata(DublinCore(obj), [IDublinCore], message) message._payload = payload initializeObjectFromSchemata(obj, iterSchemata(obj), message) elif HAS_ARCHETYPES: # AT initializeObject(obj, iterFields(obj), message)
def demarshall(ob, message): types_tool = api.portal.get_tool('portal_types') fti = types_tool.get(ob.portal_type) if IDexterityFTI.providedBy(fti): # DX try: initializeObjectFromSchemata(ob, iterSchemata(ob), message) except Exception: raise # import pdb; pdb.set_trace() # initializeObjectFromSchemata(ob, iterSchemata(ob), message) elif HAS_ARCHETYPES: # AT initializeObject(ob, iterFields(ob), message)
def marshall(ob): types_tool = api.portal.get_tool('portal_types') fti = types_tool.get(ob.portal_type) # noinspection PyUnresolvedReferences if HAS_DEXTERITY and IDexterityFTI.providedBy(fti): # DX message = constructMessageFromSchemata(ob, iterSchemata(ob)) elif HAS_ARCHETYPES and hasattr(Acquisition.aq_base(ob), 'schema'): # AT message = constructMessage(ob, iterFields(ob)) else: # Other schemata = tuple(ob.__provides__.interfaces()) message = constructMessageFromSchemata(ob, schemata) return message
def marshall(obj): # noinspection PyUnresolvedReferences if HAS_DEXTERITY and IDexterityContent.providedBy(obj): # DX message = constructMessageFromSchemata(obj, iterSchemata(obj)) # Ensure that all DC fields are included dc = constructMessageFromSchemata(DublinCore(obj), [IDublinCore]) for name in [key for key in dc.keys() if not message[key]]: if name in message.keys(): del message[name] message[name] = dc[name] elif HAS_ARCHETYPES and hasattr(Acquisition.aq_base(obj), 'schema'): # AT message = constructMessage(obj, iterFields(obj)) else: # Other schemata = tuple(obj.__provides__.interfaces()) message = constructMessageFromSchemata(obj, schemata) return message
def demarshall(self, instance, data, **kwargs): message = message_from_string(data) initializeObject(instance, iterFields(instance), message)
def marshall(self, instance, **kwargs): message = constructMessage(instance, iterFields(instance)) content_type = message.get_content_type() data = to_string(message) length = len(data) return content_type, length, data