Commit 08accfb8 authored by Marcel Rieger's avatar Marcel Rieger
Browse files

Add signature mapping tool and add convenience to GET and POST methods of extensions.

parent 2ba94a82
......@@ -35,6 +35,14 @@ class RootController(AbstractController):
self.common_js = []
self.common_css = []
@cherrypy.expose
@cherrypy.tools.workspace(on=False)
@cherrypy.tools.signature()
def sigtest(self, o, l, i, s):
for elem in (o, l, i, s):
print "%s (%s)" % (elem, type(elem))
return "geht"
def add_common_js(self, filepath):
self.common_js.append(filepath)
......
......@@ -260,6 +260,9 @@ class Server(object):
from vispa.tools.ajax import AjaxTool
cherrypy.tools.ajax = AjaxTool()
from vispa.tools.signature import SignatureMapper
cherrypy.tools.signature = SignatureMapper()
try:
from ws4py.server.cherrypyserver import WebSocketTool # @UnresolvedImport
cherrypy.tools.websocket = WebSocketTool()
......
......@@ -995,11 +995,14 @@ var ExtensionView = Emitter.extend({
_workspaceId: this.getWorkspaceId(),
_viewId: this.getId()
});
var promise = $.ajax({
var req = {
type: method,
url: this.dynamic(url),
data: data
});
};
if (typeof(data) == "string")
req.contentType = "application/json";
var promise = $.ajax(req);
if ($.isFunction(successCallback))
promise.done(successCallback);
if ($.isFunction(failCallback))
......
# -*- coding: utf-8 -*-
# imports
import cherrypy
import vispa
import logging
import json
logger = logging.getLogger(__name__)
class SignatureMapper(cherrypy.Tool):
def __init__(self):
cherrypy.Tool.__init__(self, 'before_handler', self.before_handler, priority=55)
def before_handler(self):
req = cherrypy.request
if req.method != "POST" or req.headers["Content-Type"] != "application/json":
return
if len(req.params.keys()):
return
try:
data = json.loads(req.body.fp.read())
cherrypy.request.params.update(data)
except:
pass
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment