Browse Source

incorporate djextdirect updates

Natenom/support-murmur-13-1446181288462
Michael Ziegler 14 years ago
parent
commit
10d0a1b81f
  1. 22
      pyweb/djextdirect/client.py
  2. 4
      pyweb/djextdirect/provider.py

22
pyweb/djextdirect/client.py

@ -15,7 +15,11 @@
* GNU General Public License for more details.
"""
import simplejson
try:
import simplejson
except ImportError:
import json as simplejson
import httplib
from threading import Lock
from urlparse import urljoin, urlparse
@ -100,12 +104,15 @@ class Client(object):
self.cookie = cookie
purl = urlparse( self.apiurl )
conn = httplib.HTTPConnection( purl.netloc )
conn = {
"http": httplib.HTTPConnection,
"https": httplib.HTTPSConnection
}[purl.scheme.lower()]( purl.netloc )
conn.putrequest( "GET", purl.path )
conn.endheaders()
resp = conn.getresponse()
conn.close()
foundvars = lexjs( resp.read() )
conn.close()
self.api = foundvars[apiname]
self.routerurl = urljoin( self.apiurl, self.api["url"] )
@ -137,16 +144,18 @@ class Client(object):
})
purl = urlparse( self.routerurl )
conn = httplib.HTTPConnection( purl.netloc )
conn = {
"http": httplib.HTTPConnection,
"https": httplib.HTTPSConnection
}[purl.scheme.lower()]( purl.netloc )
conn.putrequest( "POST", purl.path )
conn.putheader( "Content-Type", "application/json" )
conn.putheader( "Content-Length", len(data) )
conn.putheader( "Content-Length", str(len(data)) )
if self.cookie:
conn.putheader( "Cookie", self.cookie )
conn.endheaders()
conn.send( data )
resp = conn.getresponse()
conn.close()
if resp.status != 200:
raise RequestError( resp.status, resp.reason )
@ -161,6 +170,7 @@ class Client(object):
if cookie:
self.cookie = cookie.split(';')[0]
conn.close()
return respdata['result']
def get_object( self, action ):

4
pyweb/djextdirect/provider.py

@ -105,7 +105,7 @@ class Provider( object ):
if flags is None:
flags = {}
self.classes[ clsname ][ method.__name__ ] = method
method.EXT_argnames = inspect.getargspec( method ).args[1:]
method.EXT_argnames = inspect.getargspec( method )[0][1:]
method.EXT_len = len( method.EXT_argnames )
method.EXT_flags = flags
return method
@ -158,7 +158,7 @@ class Provider( object ):
except (MultiValueDictKeyError, KeyError), err:
try:
rawjson = simplejson.loads( request.raw_post_data )
except simplejson.JSONDecodeError:
except getattr( simplejson, "JSONDecodeError", ValueError ):
return HttpResponse( simplejson.dumps({
'type': 'exception',
'message': 'malformed request',

Loading…
Cancel
Save