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)
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)
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
def child_pvd(self, ctx): graph = allGraphs(literalToday()) return viewFunc('next4Trains', graph, STATION['PVD'])