def make_dom_node(attachment, document): """Create a DOM element node for this attachment. 'document' -- A DOM document node in which to create the element. returns -- A DOM element node.""" # Create an attachment element. node = document.createElement("attachment") # Is it a null attachment? if attachment is None: # Then that's it. return node mime_type = attachment.GetMimeType() # Create and add the description node. child = xmlutil.create_dom_text_element(document, "description", attachment.GetDescription()) node.appendChild(child) # Create and add the MIME type node. child = xmlutil.create_dom_text_element(document, "mime-type", mime_type) node.appendChild(child) # Create and add the file name node. child = xmlutil.create_dom_text_element(document, "filename", attachment.GetFileName()) node.appendChild(child) # Create a location element, to include attachment data by # reference. location = attachment.GetLocation() child = xmlutil.create_dom_text_element(document, "location", location) node.appendChild(child) return node
def _create_dom_properties(element, properties): """Add user properties to a DOM element. 'element' -- A DOM element node to which properties are to be added as children. 'properties' -- A map from property names to values.""" document = element.ownerDocument for name, value in properties.items(): prop_element = xmlutil.create_dom_text_element( document, "property", str(value)) prop_element.setAttribute("name", name) element.appendChild(prop_element)
def make_dom_node(attachment, document): """Create a DOM element node for this attachment. 'document' -- A DOM document node in which to create the element. returns -- A DOM element node.""" # Create an attachment element. node = document.createElement("attachment") # Is it a null attachment? if attachment is None: # Then that's it. return node mime_type = attachment.GetMimeType() # Create and add the description node. child = xmlutil.create_dom_text_element( document, "description", attachment.GetDescription()) node.appendChild(child) # Create and add the MIME type node. child = xmlutil.create_dom_text_element( document, "mime-type", mime_type) node.appendChild(child) # Create and add the file name node. child = xmlutil.create_dom_text_element( document, "filename", attachment.GetFileName()) node.appendChild(child) # Create a location element, to include attachment data by # reference. location = attachment.GetLocation() child = xmlutil.create_dom_text_element(document, "location", location) node.appendChild(child) return node
def create_dom_for_group(document, group): """Create a DOM element node for 'group'. 'document' -- The DOM document object in which to create the element. 'group' -- A 'Group' instance. returns -- A DOM element node.""" element = document.createElement("group") element.setAttribute("id", group.GetId()) for user_id in group: user_id_element = xmlutil.create_dom_text_element( document, "user-id", user_id) element.appendChild(user_id_element) return element