def __init__(self, networking):
     self.networking = networking
     self.datahandler = DataHandler()
class CherrypyHandler(RESTResource):

    datahandler = None

    def __init__(self, networking):
        self.networking = networking
        self.datahandler = DataHandler()

    def handle_GET(self, *vpath, **params):
        retval = "/" + str('/'.join(vpath)) + "/"

        if retval is "//":
            retval = "/"

        key = None

        if "apitoken" in params:
            key = params["apitoken"]

        response = self.datahandler.handleIt(0, retval, key, None)

        cherrypy.response.status = response.code
        return response.json

    def handle_POST(self, *vpath, **params):
        retval = "/" + str('/'.join(vpath)) + "/"

        if retval is "//":
            retval = "/"

        if 'data' not in params:
            params['data'] = ""

        key = None

        if "apitoken" in params:
            key = params["apitoken"]

        response = self.datahandler.handleIt(1, retval, key,
                                             str(params['data']))

        cherrypy.response.status = response.code
        return response.json

    def handle_PUT(self, *vpath, **params):
        retval = "/" + str('/'.join(vpath)) + "/"

        if retval is "//":
            retval = "/"

        if 'data' not in params:
            params['data'] = ""

        key = None

        if "apitoken" in params:
            key = params["apitoken"]

        response = self.datahandler.handleIt(2, retval, key,
                                             str(params['data']))

        cherrypy.response.status = response.code
        return response.json

    def handle_DELETE(self, *vpath, **params):
        retval = "/" + str('/'.join(vpath)) + "/"

        if retval is "//":
            retval = "/"

        key = None

        if "apitoken" in params:
            key = params["apitoken"]

        response = self.datahandler.handleIt(3, retval, key, None)

        cherrypy.response.status = response.code
        return response.json
 def __init__(self, networking):
     self.networking = networking
     self.datahandler = DataHandler()
class CherrypyHandler(RESTResource):

    datahandler = None

    def __init__(self, networking):
        self.networking = networking
        self.datahandler = DataHandler()

    def handle_GET(self, *vpath, **params):
        retval = "/"+str('/'.join(vpath))+"/"

        if retval is "//":
          retval = "/"

        key = None

        if "apitoken" in params:
          key = params["apitoken"]

        response = self.datahandler.handleIt(0, retval, key, None)

        cherrypy.response.status = response.code
        return response.json

    def handle_POST(self, *vpath, **params):
        retval = "/"+str('/'.join(vpath))+"/"

        if retval is "//":
          retval = "/"

        if 'data' not in params:
          params['data'] = ""

        key = None

        if "apitoken" in params: 
          key = params["apitoken"]

        response = self.datahandler.handleIt(1, retval, key, str(params['data']))

        cherrypy.response.status = response.code
        return response.json

    def handle_PUT(self, *vpath, **params):
        retval = "/"+str('/'.join(vpath))+"/"

        if retval is "//":
          retval = "/"

        if 'data' not in params:
          params['data'] = ""


        key = None

        if "apitoken" in params:
          key = params["apitoken"]

        response = self.datahandler.handleIt(2, retval, key, str(params['data']))

        cherrypy.response.status = response.code
        return response.json

    def handle_DELETE(self, *vpath, **params):
        retval = "/"+str('/'.join(vpath))+"/"

        if retval is "//":
          retval = "/"

        key = None

        if "apitoken" in params:
          key = params["apitoken"]

        response = self.datahandler.handleIt(3, retval, key,  None)

        cherrypy.response.status = response.code
        return response.json
class TwistedHandler(Resource):

    networking = None

    isLeaf = True

    def __init__(self, networking):
        self.networking = networking
        self.datahandler = DataHandler()
        Resource.__init__(self)

    def render_GET(self, request):

        key = None

        if "apitoken" in request.args:
            key = request.args['apitoken']

        response = self.datahandler.handleIt(0, request.path, key, None)

        request.setResponseCode(response.code)
        return response.json

    def render_POST(self, request):

        try:
            data = request.args['data'][0]
        except:
            data = ""

        key = None

        if "apitoken" in request.args:
            key = request.args['apitoken']

        response = self.datahandler.handleIt(1, request.path, key, data)

        request.setResponseCode(response.code)
        return response.json

    def render_PUT(self, request):

        try:
            data = request.args['data'][0]
        except:
            data = ""

        key = None

        if "apitoken" in request.args:
            key = request.args['apitoken']

        response = self.datahandler.handleIt(2, request.path, key, data)

        request.setResponseCode(response.code)
        return response.json

    def render_DELETE(self, request):
        key = None

        if "apitoken" in request.args:
            key = request.args['apitoken']

        response = self.datahandler.handleIt(3, request.path, key, None)

        request.setResponseCode(response.code)
        return response.json
class TwistedHandler(Resource):

    networking = None

    isLeaf = True

    def __init__(self, networking):
        self.networking = networking
        self.datahandler = DataHandler()
        Resource.__init__(self)

    def render_GET(self, request):

        key = None

        if "apitoken" in request.args:
            key = request.args["apitoken"]

        response = self.datahandler.handleIt(0, request.path, key, None)

        request.setResponseCode(response.code)
        return response.json

    def render_POST(self, request):

        try:
            data = request.args["data"][0]
        except:
            data = ""

        key = None

        if "apitoken" in request.args:
            key = request.args["apitoken"]

        response = self.datahandler.handleIt(1, request.path, key, data)

        request.setResponseCode(response.code)
        return response.json

    def render_PUT(self, request):

        try:
            data = request.args["data"][0]
        except:
            data = ""

        key = None

        if "apitoken" in request.args:
            key = request.args["apitoken"]

        response = self.datahandler.handleIt(2, request.path, key, data)

        request.setResponseCode(response.code)
        return response.json

    def render_DELETE(self, request):
        key = None

        if "apitoken" in request.args:
            key = request.args["apitoken"]

        response = self.datahandler.handleIt(3, request.path, key, None)

        request.setResponseCode(response.code)
        return response.json