Mercurial > hg > decoupage
comparison decoupage/formats.py @ 60:cf18ea0313f9
add some RSS
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sun, 21 Nov 2010 17:00:02 -0800 |
parents | 07cf168aa98c |
children | 262fb90a54b4 |
comparison
equal
deleted
inserted
replaced
59:07cf168aa98c | 60:cf18ea0313f9 |
---|---|
1 """ | 1 """ |
2 pluggable formats for directory listings | 2 pluggable formats for directory listings |
3 """ | 3 """ |
4 | 4 |
5 import datetime | |
6 import PyRSS2Gen | |
7 from utils import link | |
5 try: | 8 try: |
6 import json as json | 9 import json as json |
7 except ImportError: | 10 except ImportError: |
8 import simplejson as json | 11 import simplejson as json |
9 | 12 |
11 """ | 14 """ |
12 JSON format for index pages | 15 JSON format for index pages |
13 just (basically) return the data | 16 just (basically) return the data |
14 """ | 17 """ |
15 | 18 |
16 def __init__(self, app, foo): | 19 def __init__(self, app): |
17 self.app = app | 20 self.app = app |
18 | 21 |
19 def __call__(self, request, data): | 22 def __call__(self, request, data): |
20 | 23 |
21 # fix datetime | 24 # fix datetime |
32 self.app = app # the decoupage | 35 self.app = app # the decoupage |
33 self.count = int(count) | 36 self.count = int(count) |
34 self.cascade = cascade | 37 self.cascade = cascade |
35 | 38 |
36 def __call__(self, request, data): | 39 def __call__(self, request, data): |
37 import pdb; pdb.set_trace() | 40 items = [ PyRSS2Gen.RSSItem(title=item['name'], |
41 description=item['description'] or item['name'], | |
42 pubDate=item['modified'], | |
43 guid=PyRSS2Gen.Guid(link(request, item['path']))) | |
44 for item in data['files'] ] | |
45 path_link = link(request, data['path']) | |
46 rss = PyRSS2Gen.RSS2(title=data['title'] or data['path'], | |
47 link=path_link, | |
48 description=data['title'] or data['path'], | |
49 lastBuildDate = datetime.datetime.now(), | |
50 items=items | |
51 ) | |
52 return 'application/rss+xml', rss.to_xml() |