Support generation of static JSONP.
This commit is contained in:
parent
5a458da376
commit
e488664efe
@ -20,7 +20,8 @@ parser.add_argument('--db', default=None,
|
|||||||
|
|
||||||
|
|
||||||
def freeze(result, format='csv', filename='freeze.csv',
|
def freeze(result, format='csv', filename='freeze.csv',
|
||||||
prefix='.', meta={}, indent=2, mode='list', wrap=True, **kw):
|
prefix='.', meta={}, indent=2, mode='list',
|
||||||
|
wrap=True, callback=None, **kw):
|
||||||
"""
|
"""
|
||||||
Perform a data export of a given result set. This is a very
|
Perform a data export of a given result set. This is a very
|
||||||
flexible exporter, allowing for various output formats, metadata
|
flexible exporter, allowing for various output formats, metadata
|
||||||
@ -54,7 +55,8 @@ def freeze(result, format='csv', filename='freeze.csv',
|
|||||||
|
|
||||||
*json*
|
*json*
|
||||||
A JSON file containing a list of dictionaries for each row
|
A JSON file containing a list of dictionaries for each row
|
||||||
in the table.
|
in the table. If a ``callback`` is given, JSON with padding
|
||||||
|
(JSONP) will be generated.
|
||||||
|
|
||||||
*tabson*
|
*tabson*
|
||||||
Tabson is a smart combination of the space-efficiency of the
|
Tabson is a smart combination of the space-efficiency of the
|
||||||
@ -67,6 +69,7 @@ def freeze(result, format='csv', filename='freeze.csv',
|
|||||||
'prefix': prefix,
|
'prefix': prefix,
|
||||||
'meta': meta,
|
'meta': meta,
|
||||||
'indent': indent,
|
'indent': indent,
|
||||||
|
'callback': callback,
|
||||||
'mode': mode,
|
'mode': mode,
|
||||||
'wrap': wrap
|
'wrap': wrap
|
||||||
})
|
})
|
||||||
|
|||||||
@ -37,8 +37,13 @@ class JSONSerializer(Serializer):
|
|||||||
for path, result in self.buckets.items():
|
for path, result in self.buckets.items():
|
||||||
result = self.wrap(result)
|
result = self.wrap(result)
|
||||||
fh = open(path, 'wb')
|
fh = open(path, 'wb')
|
||||||
json.dump(result, fh,
|
data = json.dumps(result,
|
||||||
cls=JSONEncoder,
|
cls=JSONEncoder,
|
||||||
indent=self.export.get_int('indent'))
|
indent=self.export.get_int('indent'))
|
||||||
|
if self.export.get('callback'):
|
||||||
|
data = "%s && %s(%s);" % (self.export.get('callback'),
|
||||||
|
self.export.get('callback'),
|
||||||
|
data)
|
||||||
|
fh.write(data)
|
||||||
fh.close()
|
fh.close()
|
||||||
|
|
||||||
|
|||||||
2
setup.py
2
setup.py
@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='dataset',
|
name='dataset',
|
||||||
version='0.3.10',
|
version='0.3.11',
|
||||||
description="Toolkit for Python-based data processing.",
|
description="Toolkit for Python-based data processing.",
|
||||||
long_description="",
|
long_description="",
|
||||||
classifiers=[
|
classifiers=[
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user