Example #1
0
    def locateChild(self, ctx, segments):
        if segments == ('all',):
            g = allGraphs(literalToday())
            return RdfXMLPage(g.serialize(format='xml')), []

        print segments
        # limiting to today's data only because it was easier to code quickly
        if len(segments) == 2 and segments[0] == str(literalToday()) and segments[1].isalnum():
            return RdfXMLPage(readSubgraphXML("graph/%s/%s" % segments[:2])), []
        return rend.Page.locateChild(self, ctx, segments)
Example #2
0
    def locateChild(self, ctx, segments):
        if segments == ('all', ):
            g = allGraphs(literalToday())
            return RdfXMLPage(g.serialize(format='xml')), []

        print segments
        # limiting to today's data only because it was easier to code quickly
        if len(segments) == 2 and segments[0] == str(
                literalToday()) and segments[1].isalnum():
            return RdfXMLPage(readSubgraphXML("graph/%s/%s" %
                                              segments[:2])), []
        return rend.Page.locateChild(self, ctx, segments)
Example #3
0
    def child_okj(self, ctx):
        graph = allGraphs(literalToday())
        child = viewFunc('trainsToday', graph, literalToday(), STATION['OKJ'])
        def update(self, ctx):
            request = inevow.IRequest(ctx)
            graph = Graph()
            graph.parse("passwd.n3", format="n3")
            g = lambda pred: graph.value(TT['okjUpdate'], pred)
            if ((request.getUser(), request.getPassword()) ==
                (g(TT['user']), g(TT['password']))):
                graph = getGraph()
                addTrainsAtStation(graph, STATION['OKJ'], literalToday())
                return "update ok"
            else:
                request.setHeader('WWW-Authenticate',
                                  'Basic realm="traintimes"')
                request.setResponseCode(http.UNAUTHORIZED)
            return "Authentication required." 

        child.child_update = lambda ctx: update(child, ctx)
        return child
Example #4
0
    def child_okj(self, ctx):
        graph = allGraphs(literalToday())
        child = viewFunc('trainsToday', graph, literalToday(), STATION['OKJ'])

        def update(self, ctx):
            request = inevow.IRequest(ctx)
            graph = Graph()
            graph.parse("passwd.n3", format="n3")
            g = lambda pred: graph.value(TT['okjUpdate'], pred)
            if ((request.getUser(),
                 request.getPassword()) == (g(TT['user']), g(TT['password']))):
                graph = getGraph()
                addTrainsAtStation(graph, STATION['OKJ'], literalToday())
                return "update ok"
            else:
                request.setHeader('WWW-Authenticate',
                                  'Basic realm="traintimes"')
                request.setResponseCode(http.UNAUTHORIZED)
            return "Authentication required."

        child.child_update = lambda ctx: update(child, ctx)
        return child
Example #5
0
 def child_pvd(self, ctx):
     graph = allGraphs(literalToday())
     return viewFunc('next4Trains', graph, STATION['PVD'])
Example #6
0
 def child_pvd(self, ctx):
     graph = allGraphs(literalToday())
     return viewFunc('next4Trains', graph, STATION['PVD'])