Browse Source

update djextdirect

Natenom/support-murmur-13-1446181288462
Michael Ziegler 14 years ago
parent
commit
4414375d31
  1. 2
      pyweb/djextdirect/__init__.py
  2. 10
      pyweb/djextdirect/provider.py

2
pyweb/djextdirect/__init__.py

@ -15,7 +15,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
""" """
VERSION = ( 0, 3 )
VERSION = ( 0, 4 )
VERSIONSTR = "v%d.%d" % VERSION VERSIONSTR = "v%d.%d" % VERSION

10
pyweb/djextdirect/provider.py

@ -29,7 +29,6 @@ from django.conf import settings
from django.conf.urls.defaults import patterns from django.conf.urls.defaults import patterns
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.utils.datastructures import MultiValueDictKeyError from django.utils.datastructures import MultiValueDictKeyError
from django.views.decorators.csrf import csrf_exempt
def getname( cls_or_name ): def getname( cls_or_name ):
""" If cls_or_name is not a string, return its __name__. """ """ If cls_or_name is not a string, return its __name__. """
@ -113,7 +112,6 @@ class Provider( object ):
method.EXT_flags = flags method.EXT_flags = flags
return method return method
@csrf_exempt
def get_api( self, request ): def get_api( self, request ):
""" Introspect the methods and get a JSON description of this API. """ """ Introspect the methods and get a JSON description of this API. """
actdict = {} actdict = {}
@ -134,11 +132,17 @@ class Provider( object ):
}))] }))]
if self.autoadd: if self.autoadd:
lines.append(
"""Ext.Ajax.on("beforerequest", function(conn, options){"""
""" if( !options.headers )"""
""" options.headers = {};"""
""" options.headers["X-CSRFToken"] = Ext.util.Cookies.get("csrftoken");"""
"""});"""
)
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 ), mimetype="text/javascript" )
@csrf_exempt
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.

Loading…
Cancel
Save