Example #1
0
    def child_addCommand(self, ctx):
        request = inevow.IRequest(ctx)
        log.warn("addCommand", request)
        if request.method != "POST":
            # there's a correct http status for this
            raise ValueError("addCommand only takes POST")

        # nevow has a better form than this, i hope
        request.content.seek(0)
        args = dict(url.unquerify(request.content.read()))

        cmd = self.cmdlog.addCommand(URIRef(args["uri"]), nowLiteral(), self.user)

        # accept: json for AJAX

        # this kind of stuff was not working on the url.here redirect:
        # request.received_headers['host'] = 'bigasterisk.com'
        # request.prepath = ['magma']
        # request.setHost('bigasterisk.com', 80)

        message = self.addedCommandMessage(cmd)

        class Ret(rend.Page):
            def renderHTTP(self, ctx):
                req = inevow.IRequest(ctx)
                req.setHeader("Location", url.URL.fromString("http://bigasterisk.com/magma").add("added", cmd))
                # req.setResponseCode(303) # this would be right for non-js browsers, but i don't know how to make the page jquery read my message and not follow the redir
                req.write(message.encode("utf8"))
                req.finish()
                return ""

        return Ret()
Example #2
0
    def testQuoting(self):
        context = None
        scheme = 'http'
        loc = 'localhost'
        path = ('baz', 'buz', '/fuzz/')
        query = [("foo", "bar"), ("baz", "=quux"), ("foobar", "?")]
        fragment = 'futz'
        u = url.URL(scheme, loc, path, query, fragment)
        s = flatten(url.URL(scheme, loc, path, query, fragment))

        parsedScheme, parsedLoc, parsedPath, parsedQuery, parsedFragment = urlsplit(s)

        self.assertEqual(scheme, parsedScheme)
        self.assertEqual(loc, parsedLoc)
        self.assertEqual('/' + '/'.join([quote(p,safe='') for p in path]), parsedPath)
        self.assertEqual(query, url.unquerify(parsedQuery))
        self.assertEqual(fragment, parsedFragment)
Example #3
0
    def testQuoting(self):
        context = None
        scheme = 'http'
        loc = 'localhost'
        path = ('baz', 'buz', '/fuzz/')
        query = [("foo", "bar"), ("baz", "=quux"), ("foobar", "?")]
        fragment = 'futz'
        u = url.URL(scheme, loc, path, query, fragment)
        s = flatten(url.URL(scheme, loc, path, query, fragment))

        parsedScheme, parsedLoc, parsedPath, parsedQuery, parsedFragment = urlparse.urlsplit(s)

        self.assertEquals(scheme, parsedScheme)
        self.assertEquals(loc, parsedLoc)
        self.assertEquals('/' + '/'.join(map(lambda p: urllib.quote(p,safe=''),path)), parsedPath)
        self.assertEquals(query, url.unquerify(parsedQuery))
        self.assertEquals(fragment, parsedFragment)
Example #4
0
    def testQuoting(self):
        context = None
        scheme = "http"
        loc = "localhost"
        path = ("baz", "buz", "/fuzz/")
        query = [("foo", "bar"), ("baz", "=quux"), ("foobar", "?")]
        fragment = "futz"
        u = url.URL(scheme, loc, path, query, fragment)
        s = flatten(url.URL(scheme, loc, path, query, fragment))

        parsedScheme, parsedLoc, parsedPath, parsedQuery, parsedFragment = urllib.parse.urlsplit(s)

        self.assertEqual(scheme, parsedScheme)
        self.assertEqual(loc, parsedLoc)
        self.assertEqual("/" + "/".join([urllib.parse.quote(p, safe="") for p in path]), parsedPath)
        self.assertEqual(query, url.unquerify(parsedQuery))
        self.assertEqual(fragment, parsedFragment)
Example #5
0
    def child_addCommand(self, ctx):
        request = inevow.IRequest(ctx)
        log.warn("addCommand", request)
        if request.method != "POST":
            # there's a correct http status for this
            raise ValueError("addCommand only takes POST")

        # nevow has a better form than this, i hope
        request.content.seek(0)
        args = dict(url.unquerify(request.content.read()))

        cmd = self.cmdlog.addCommand(URIRef(args['uri']), nowLiteral(),
                                     self.user)

        # accept: json for AJAX

        # this kind of stuff was not working on the url.here redirect:
        #request.received_headers['host'] = 'bigasterisk.com'
        #request.prepath = ['magma']
        #request.setHost('bigasterisk.com', 80)

        message = self.addedCommandMessage(cmd)

        class Ret(rend.Page):
            def renderHTTP(self, ctx):
                req = inevow.IRequest(ctx)
                req.setHeader(
                    "Location",
                    url.URL.fromString('http://bigasterisk.com/magma').add(
                        'added', cmd))
                # req.setResponseCode(303) # this would be right for non-js browsers, but i don't know how to make the page jquery read my message and not follow the redir
                req.write(message.encode('utf8'))
                req.finish()
                return ''

        return Ret()
Example #6
0
    def child_addCommand(self, ctx):


        # this is obsoleted by a magma/addCommand handler

        
        request = inevow.IRequest(ctx)
        if request.method != "POST":
            # there's a correct http status for this
            raise ValueError("addCommand only takes POST")

        # nevow has a better form than this, i hope
        request.content.seek(0)
        args = dict(url.unquerify(request.content.read()))

        t = iso8601.tostring(float(args.get('time', time.time())),
                             # using current timezone, even for passed-in value
                             (time.timezone, time.altzone)[time.daylight]) 
        user = URIRef(args.get('user', 'http://bigasterisk.com/magma/user_tbd'))
        self.cmdlog.addCommand(URIRef(args['uri']),
                               Literal(t, datatype=XS['dateTime']),
                               user)

        return url.URL.fromString('http://bigasterisk.com/magma/heater/')# TODO#returnPage("text/javascript",