1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
-
-
+
+
+
+
+
+
+
+
+
|
"""
This file is part of the web2py Web Framework
Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu>
License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
"""
import datetime
from storage import Storage
from html import TAG
from html import xmlescape
from languages import lazyT
import contrib.simplejson as simplejson
import contrib.rss2 as rss2
import contrib.rss2 as rss2
try:
import json as json_parser # try stdlib (Python 2.6)
except ImportError:
try:
import simplejson as json_parser # try external module
except:
import contrib.simplejson as json_parser # fallback to pure-Python module
def custom_json(o):
if hasattr(o,'custom_json') and callable(o.custom_json):
return o.custom_json()
if isinstance(o, (datetime.date,
datetime.datetime,
datetime.time)):
return o.isoformat()[:19].replace('T',' ')
|
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
-
+
|
def xml(value, encoding='UTF-8', key='document'):
return ('<?xml version="1.0" encoding="%s"?>' % encoding) + str(xml_rec(value,key))
def json(value,default=custom_json):
return simplejson.dumps(value,default=default)
return json_parser.dumps(value,default=default)
def csv(value):
return ''
def rss(feed):
|
71
72
73
74
75
76
77
78
|
78
79
80
81
82
83
84
85
86
87
|
+
+
|
description=entry['description'],
pubDate=entry.get('created_on', now)
)\
for entry in feed['entries']
]
)
return rss2.dumps(rss)
|