Browse Source

[django 1.7] update djextdirect convenience copy

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

4
pyweb/djextdirect/formprovider.py

@ -178,7 +178,7 @@ class FormProvider(Provider):
self.forms = {} self.forms = {}
def get_choices_combo_src( self, request ): def get_choices_combo_src( self, request ):
return HttpResponse( EXT_DYNAMICCHOICES_COMBO, mimetype="text/javascript" )
return HttpResponse( EXT_DYNAMICCHOICES_COMBO, content_type="text/javascript" )
def register_form( self, formclass ): def register_form( self, formclass ):
""" Register a Django Form class. """ """ Register a Django Form class. """
@ -300,7 +300,7 @@ class FormProvider(Provider):
"}"), "}"),
} }
return HttpResponse( mark_safe( clscode ), mimetype="text/javascript" )
return HttpResponse( mark_safe( clscode ), content_type="text/javascript" )
def get_field_choices( self, formname, request, pk, field ): def get_field_choices( self, formname, request, pk, field ):
""" Create a bound instance of the form and return choices from the given field. """ """ Create a bound instance of the form and return choices from the given field. """

14
pyweb/djextdirect/provider.py

@ -131,7 +131,7 @@ class Provider( object ):
"url": reverse( self.request ), "url": reverse( self.request ),
"type": "remoting", "type": "remoting",
"actions": self.build_api_dict() "actions": self.build_api_dict()
}, cls=DjangoJSONEncoder), mimetype="application/json" )
}, cls=DjangoJSONEncoder), content_type="application/json" )
def get_api( self, request ): def get_api( self, request ):
""" Introspect the methods and get a javascript description of the API """ Introspect the methods and get a javascript description of the API
@ -154,7 +154,7 @@ class Provider( object ):
) )
lines.append( "Ext.Direct.addProvider( %s );" % self.name ) lines.append( "Ext.Direct.addProvider( %s );" % self.name )
return HttpResponse( "\n".join( lines ), mimetype="text/javascript" )
return HttpResponse( "\n".join( lines ), content_type="text/javascript" )
def request( self, request ): def request( self, request ):
""" Implements the Router part of the Ext.Direct specification. """ Implements the Router part of the Ext.Direct specification.
@ -185,7 +185,7 @@ class Provider( object ):
'message': 'malformed request', 'message': 'malformed request',
'where': err.message, 'where': err.message,
"tid": None, # dunno "tid": None, # dunno
}, cls=DjangoJSONEncoder), mimetype="application/json" )
}, cls=DjangoJSONEncoder), content_type="application/json" )
else: else:
return self.process_normal_request( request, rawjson ) return self.process_normal_request( request, rawjson )
else: else:
@ -281,9 +281,9 @@ class Provider( object ):
}) })
if len(responses) == 1: if len(responses) == 1:
return HttpResponse( json.dumps( responses[0], cls=DjangoJSONEncoder ), mimetype="application/json" )
return HttpResponse( json.dumps( responses[0], cls=DjangoJSONEncoder ), content_type="application/json" )
else: else:
return HttpResponse( json.dumps( responses, cls=DjangoJSONEncoder ), mimetype="application/json" )
return HttpResponse( json.dumps( responses, cls=DjangoJSONEncoder ), content_type="application/json" )
def process_form_request( self, request, reqinfo ): def process_form_request( self, request, reqinfo ):
""" Router for POST requests that submit form data and/or file uploads. """ """ Router for POST requests that submit form data and/or file uploads. """
@ -339,10 +339,10 @@ class Provider( object ):
if reqinfo['upload'] == "true": if reqinfo['upload'] == "true":
return HttpResponse( return HttpResponse(
"<html><body><textarea>%s</textarea></body></html>" % json.dumps(response, cls=DjangoJSONEncoder), "<html><body><textarea>%s</textarea></body></html>" % json.dumps(response, cls=DjangoJSONEncoder),
mimetype="application/json"
content_type="application/json"
) )
else: else:
return HttpResponse( json.dumps( response, cls=DjangoJSONEncoder ), mimetype="application/json" )
return HttpResponse( json.dumps( response, cls=DjangoJSONEncoder ), content_type="application/json" )
def get_urls(self): def get_urls(self):
""" Return the URL patterns. """ """ Return the URL patterns. """

Loading…
Cancel
Save