# $SnapHashLicense:
#
# SnapLogic - Open source data services
#
# Copyright (C) 2008, SnapLogic, Inc. All rights reserved.
#
# See http://www.snaplogic.org for more information about
# the SnapLogic project.
#
# This program is free software, distributed under the terms of
# the GNU General Public License Version 2. See the LEGAL file
# at the top of the source tree.
#
# "SnapLogic" is a trademark of SnapLogic, Inc.
#
#
# $
#$Id: JSONPRP.py 1841 2008-03-24 20:24:23Z amax $
from snaplogic.rp import json_rp
class Writer(json_rp.Writer):
"""
Writes out Python objects as JSONP. All records are sent in the single JSON document representing
an array.
"""
def initialize(self, header=''):
"""Prepare the underlying stream for sending the data."""
if header is None:
header = ""
s = '%s([' % header
self.stream.write(s)
return s
def end(self, footer=''):
if footer is None:
footer = ""
s = '])%s' % footer
self.stream.write(s)
return s
|