view decoupage/formats.py @ 57:884e6c805208

more stubbing for RSS
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 18 Nov 2010 08:32:45 -0800
parents 47acf12d01e1
children 1275124ed767
line wrap: on
line source

"""
pluggable formats for directory listings
"""

try:
  import json as json
except ImportError:
  import simplejson as json

# TODO: convert this to a class
def format_json(data):

  # fix datetime
  for f in data['files']:
    if 'modified' in f:
      f['modified'] = f['modified'].ctime()

  return 'application/json', json.dumps(data['files'])
  
class RSS(object):
  """RSS for indices"""

  def __init__(self, app, count=10, cascade=False):
    self.app = app # the decoupage
    self.count = count
    self.cascade = cascade

  def __call__(self, request, data):
    pass