Projet

Général

Profil

Télécharger (2,09 ko) Statistiques
| Branche: | Tag: | Révision:

root / auquotidien / modules / pyatom / readme.txt @ 8b02623d

1
PyAtom
2

    
3

    
4
PyAtom is a Python library module I wrote to make it very easy to create
5
an Atom syndication feed.
6

    
7
http://atomenabled.org/developers/syndication/
8

    
9

    
10
I have released PyAtom under The Academic Free License 2.1.  I intend to
11
donate PyAtom to the Python Software Foundation.
12

    
13

    
14
Notes on PyAtom:
15

    
16
XML is best represented in a tree structure, and PyAtom is a set of
17
classes that automatically manage the tree structure for the user.  The
18
top level of an Atom feed is an XML "Feed" element with a "<feed>" tag;
19
the Feed element has other elements nested inside it that describe the
20
feed, and then it has 0 or more Entry elements, each of which has
21
elements that describe the Entry.
22

    
23
Take a look at RunPyAtomTestCases(), at the end of pyatom.py, for
24
example code showing how to set up a feed with an entry.
25

    
26
To create an XML document with a feed in it, the user does this:
27

    
28
xmldoc = XMLDoc()
29
feed = Feed()
30
xmldoc.root_element = feed
31

    
32
To assign an entry to a feed, the user just does this:
33

    
34
feed.entries.append(entry)
35

    
36
This adds "entry" to the internal list that keeps track of entries.
37
"entry" is now nested inside "feed", which is nested inside "xmldoc".
38

    
39
Later, when the user wants to save the XML in a file, the user can just
40
do this:
41

    
42
f = open("file.xml", "w")
43
s = str(xmldoc)
44
f.write(s)
45

    
46
To make the string from xmldoc, the XMLDoc class walks through the XML
47
elements nested inside xmldoc, asking each one to return its string.
48
Each element that has other elements nested inside does the same thing.
49
The whole tree is recursively walked, and the tags all return strings
50
that are indented properly for their level in the tree.
51

    
52
The classes that implement Atom in PyAtom just use the heck out of
53
inheritance.  There are abstract base classes that implement broadly
54
useful behavior, and lots of classes that just inherit and use this
55
behavior; but there are plenty of places where the child classes
56
overload the inherited behavior and do something different.  The way
57
Python handles inheritance made this a joy to code up.
58

    
59

    
60

    
61
If you have any questions about anything here, please contact me using
62
this email address:
63

    
64
pyatom@langri.com
(4-4/4)