コード例 #1
0
def marshall_topic_as_collection(ob):
    # noinspection PyPep8Naming
    def getNamesAndFieldsInOrder(iface):
        for field_name in getFieldNamesInOrder(iface):
            yield field_name, iface[field_name]

    return constructMessage(MockCollection(*convert(ob)),
                            getNamesAndFieldsInOrder(IMockCollection))
コード例 #2
0
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
コード例 #3
0
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
コード例 #4
0
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
コード例 #5
0
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