Commits

Sylvain Viollon  committed 56ea09f

Use json instead of simplejson if have at least Python 2.6.

  • Participants
  • Parent commits 58998dd

Comments (0)

Files changed (2)

File gp/fileupload/upload.py

 # (c) 2008 Gael Pasgrimaud and contributors
 # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
 import os
-import cgi
-import simplejson
 from webob import Request, Response, exc
 from paste.fileapp import FileApp
 from gp.fileupload.config import *
 from gp.fileupload.resource import *
 from gp.fileupload.storage import *
 
+try:
+    import json
+except ImportError:
+    import simplejson as json
+
 __all__ = ['FileUpload', 'make_app']
 
 
 
     def status(self, req):
         if self.disable_gpupload:
-            data = simplejson.dumps({'state': 2 })
+            data = json.dumps({'state': 2 })
             resp = Response()
             resp.content_type = 'application/json'
             if 'callback' in req.GET:
         resp = Response()
         resp.content_type = 'application/json'
         if 'callback' in req.GET:
-            resp.body = req.GET['callback'] + '(' + simplejson.dumps(data) + ')'
+            resp.body = req.GET['callback'] + '(' + json.dumps(data) + ')'
         else:
-            resp.body = simplejson.dumps(data)
+            resp.body = json.dumps(data)
         return resp
 
 def make_app(application, global_conf, tempdir=None, max_size=0,
 from setuptools import setup, find_packages
 import sys, os
 
-version = '1.1'
+version = '1.2dev'
 
 long_description = ''
 long_description += open('README.txt').read()
     long_description += open(os.path.join('docs', filename)).read()
     long_description += '\n'
 
+
+requires = [
+    'setuptools',
+    'Paste',
+    'WebOb',
+    ]
+
+if sys.version_info < (2, 6):
+    requires.append('simplejson')
+
 setup(name='gp.fileupload',
       version=version,
       description="A WSGI middleware to get some stats on large files upload,"
       package_data={'gp/fileupload': ['static/*',]},
       include_package_data=True,
       zip_safe=False,
-      install_requires=[
-          'setuptools',
-          'Paste',
-          'WebOb',
-          'simplejson',
-      ],
+      install_requires=requires,
       entry_points="""
       # -*- Entry points: -*-
       [paste.app_factory]