Browse Source

completely switch from simplejson to json

Natenom/support-murmur-13-1446181288462
Michael Ziegler 12 years ago
parent
commit
84701bfda7
  1. 11
      pyweb/mumble/tests.py
  2. 14
      pyweb/mumble/views.py

11
pyweb/mumble/tests.py

@ -57,10 +57,7 @@
# * Log messages: yes # * Log messages: yes
# * Instance scope: ALL # * Instance scope: ALL
try:
import simplejson
except ImportError:
import json as simplejson
import json
from django.conf import settings from django.conf import settings
from django.test import TestCase from django.test import TestCase
@ -91,7 +88,7 @@ class ExtDirectFormTestMixin(object):
def formGet( self, data=[] ): def formGet( self, data=[] ):
rawr = self.cl.post( self.api_baseurl+'/router', rawr = self.cl.post( self.api_baseurl+'/router',
data=simplejson.dumps({
data=json.dumps({
'tid': self.tid, 'tid': self.tid,
'action': ('XD_%s' % self.formname), 'action': ('XD_%s' % self.formname),
'method': 'get', 'method': 'get',
@ -100,7 +97,7 @@ class ExtDirectFormTestMixin(object):
}), }),
content_type='application/json' ) content_type='application/json' )
self.tid += 1 self.tid += 1
response = simplejson.loads(rawr.content)
response = json.loads(rawr.content)
if response['type'] == "exception": if response['type'] == "exception":
raise Exception( response["message"] ) raise Exception( response["message"] )
self.assert_( "result" in response ) self.assert_( "result" in response )
@ -117,7 +114,7 @@ class ExtDirectFormTestMixin(object):
self.tid += 1 self.tid += 1
postdata.update( data ) postdata.update( data )
rawr = self.cl.post( self.api_baseurl+'/router', data=postdata ) rawr = self.cl.post( self.api_baseurl+'/router', data=postdata )
response = simplejson.loads(rawr.content)
response = json.loads(rawr.content)
if response['type'] == "exception": if response['type'] == "exception":
raise Exception( response["message"] ) raise Exception( response["message"] )
self.assert_( "result" in response ) self.assert_( "result" in response )

14
pyweb/mumble/views.py

@ -15,11 +15,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
""" """
try:
import simplejson
except ImportError:
import json as simplejson
import json
import re import re
from StringIO import StringIO from StringIO import StringIO
@ -192,7 +188,7 @@ def show( request, server ):
return render_to_response( 'mumble/mumble.html', { return render_to_response( 'mumble/mumble.html', {
'MumbleServer': srv, 'MumbleServer': srv,
'ServerDict': simplejson.dumps(serverinfo(request, server)),
'ServerDict': json.dumps(serverinfo(request, server)),
'RegForm': regformname, 'RegForm': regformname,
'MumbleActive': True, 'MumbleActive': True,
'MumbleAccount':user, 'MumbleAccount':user,
@ -529,7 +525,7 @@ def mmng_tree( request, server ):
prefix = "" prefix = ""
return HttpResponse( return HttpResponse(
prefix + "(" + simplejson.dumps( { 'channels': chanlist, 'users': userlist } ) + ")",
prefix + "(" + json.dumps( { 'channels': chanlist, 'users': userlist } ) + ")",
mimetype='text/javascript' mimetype='text/javascript'
) )
@ -558,7 +554,7 @@ def cvp_json( request, server ):
See <http://mumble.sourceforge.net/Channel_Viewer_Protocol> See <http://mumble.sourceforge.net/Channel_Viewer_Protocol>
""" """
srv = get_object_or_404( Mumble, id=int(server) ) srv = get_object_or_404( Mumble, id=int(server) )
json = simplejson.dumps( srv.asDict( cvp_checkauth( request, srv ) ) )
json = json.dumps( srv.asDict( cvp_checkauth( request, srv ) ) )
if "callback" in request.GET: if "callback" in request.GET:
validate_jsonp_callback(request.GET["callback"]) validate_jsonp_callback(request.GET["callback"])
@ -602,6 +598,6 @@ def mumbleviewer_tree_json( request, server ):
prefix = "" prefix = ""
return HttpResponse( return HttpResponse(
prefix + "(" + simplejson.dumps( srv.asMvJson() ) + ")",
prefix + "(" + json.dumps( srv.asMvJson() ) + ")",
mimetype='text/javascript' mimetype='text/javascript'
) )
Loading…
Cancel
Save