Пример #1
0
def cloneObject(objectToClone,
                knownTypes=None,
                marshalType=True,
                knownNamespaces=None,
                encoding='utf-8'):
    if (knownTypes == None):
        knownTypes, knownNamespaces = getAgKnownTypes()
    xml = xmlmarshaller.marshal(objectToClone,
                                prettyPrint=True,
                                marshalType=marshalType,
                                knownTypes=knownTypes,
                                knownNamespaces=knownNamespaces,
                                encoding=encoding)
    clonedObject = xmlmarshaller.unmarshal(xml,
                                           knownTypes=knownTypes,
                                           knownNamespaces=knownNamespaces)
    if hasattr(objectToClone, 'fileName'):
        clonedObject.fileName = objectToClone.fileName
    if hasattr(objectToClone, "_parentDoc"):
        clonedObject._parentDoc = objectToClone._parentDoc
    try:
        clonedObject.initialize()
    except AttributeError:
        pass
    return clonedObject
Пример #2
0
def cloneObject(objectToClone, knownTypes=None, marshalType=True, knownNamespaces=None, encoding='utf-8'):
    if (knownTypes == None): 
        knownTypes, knownNamespaces = getAgKnownTypes()
    xml = xmlmarshaller.marshal(objectToClone, prettyPrint=True, marshalType=marshalType, knownTypes=knownTypes, knownNamespaces=knownNamespaces, encoding=encoding)
    clonedObject = xmlmarshaller.unmarshal(xml, knownTypes=knownTypes, knownNamespaces=knownNamespaces)
    if hasattr(objectToClone, 'fileName'):
        clonedObject.fileName = objectToClone.fileName
    if hasattr(objectToClone, "_parentDoc"):
        clonedObject._parentDoc = objectToClone._parentDoc
    try:
        clonedObject.initialize()
    except AttributeError:
        pass
    return clonedObject
Пример #3
0
def marshal(objectToSave,
            prettyPrint=True,
            marshalType=True,
            knownTypes=None,
            knownNamespaces=None,
            encoding='utf-8'):
    if (knownTypes == None):
        knownTypes, knownNamespaces = getAgKnownTypes()
    return xmlmarshaller.marshal(objectToSave,
                                 prettyPrint=prettyPrint,
                                 marshalType=marshalType,
                                 knownTypes=knownTypes,
                                 knownNamespaces=knownNamespaces,
                                 encoding=encoding)
Пример #4
0
def marshal(objectToSave, prettyPrint=True, marshalType=True, knownTypes=None, knownNamespaces=None, encoding='utf-8'):
    if (knownTypes == None): 
        knownTypes, knownNamespaces = getAgKnownTypes()
    return xmlmarshaller.marshal(objectToSave, prettyPrint=prettyPrint, marshalType=marshalType, knownTypes=knownTypes, knownNamespaces=knownNamespaces, encoding=encoding)