Atom1Feed
This class generates syndication feeds in the Atom 1.0 format as defined by RFC 4287. It provides functionality to serialize feed metadata and individual entries into a compliant XML structure, including support for authors, categories, and enclosures. The class handles the conversion of dates to the RFC 3339 standard and manages XML namespaces and language attributes.
Attributes
| Attribute | Type | Description |
|---|---|---|
| content_type | string = "application/atom+xml; charset=utf-8" | The HTTP Content-Type header value used for the Atom feed response. |
| ns | string = "http://www.w3.org/2005/Atom" | The XML namespace URI used for the Atom feed elements. |
Constructor
Signature
def Atom1Feed()
Methods
write()
@classmethod
def write(
outfile: file-like object,
encoding: string
)
Writes the complete Atom 1.0 feed document to the specified file-like object using the provided encoding.
Parameters
| Name | Type | Description |
|---|---|---|
| outfile | file-like object | The destination stream where the XML content of the feed will be written. |
| encoding | string | The character encoding to use for the output XML document. |
root_attributes()
@classmethod
def root_attributes() - > dict
Generates the top-level attributes for the feed element, including the Atom namespace and optional language metadata.
Returns
| Type | Description |
|---|---|
dict | A dictionary containing the XML namespace and, if available, the 'xml:lang' attribute. |
add_root_elements()
@classmethod
def add_root_elements(
handler: [SimplerXMLGenerator](../xmlutils/simplerxmlgenerator.md?sid=django_utils_xmlutils_simplerxmlgenerator)
)
Appends global feed metadata such as title, links, unique identifiers, and author information to the XML handler.
Parameters
| Name | Type | Description |
|---|---|---|
| handler | [SimplerXMLGenerator](../xmlutils/simplerxmlgenerator.md?sid=django_utils_xmlutils_simplerxmlgenerator) | The XML generator instance used to append root-level elements to the feed. |
write_items()
@classmethod
def write_items(
handler: [SimplerXMLGenerator](../xmlutils/simplerxmlgenerator.md?sid=django_utils_xmlutils_simplerxmlgenerator)
)
Iterates through all feed items and triggers the generation of individual entry elements within the XML document.
Parameters
| Name | Type | Description |
|---|---|---|
| handler | [SimplerXMLGenerator](../xmlutils/simplerxmlgenerator.md?sid=django_utils_xmlutils_simplerxmlgenerator) | The XML generator instance used to write the collection of entry elements. |
add_item_elements()
@classmethod
def add_item_elements(
handler: [SimplerXMLGenerator](../xmlutils/simplerxmlgenerator.md?sid=django_utils_xmlutils_simplerxmlgenerator),
item: dict
)
Populates a specific entry element with detailed item metadata including publication dates, author details, summaries, and enclosures.
Parameters
| Name | Type | Description |
|---|---|---|
| handler | [SimplerXMLGenerator](../xmlutils/simplerxmlgenerator.md?sid=django_utils_xmlutils_simplerxmlgenerator) | The XML generator instance used to append elements to the current entry. |
| item | dict | A dictionary containing the data for a single feed entry, such as title, link, and description. |