def default(self, uid): if uid.endswith('.rdf'): # serve the data cherrypy.response.headers['Content-Type'] = 'application/rdf+xml; charset=UTF-8;' print USE_SPARQL sparql_match = False if USE_SPARQL: #print "USING SPARQL" # check sparql endpoint connect = VODBC.connect() cursor = connect.cursor() ss = SparqlSpace('http://dbtune.org/myspace/uid/'+str(uid.rsplit('.rdf')[0]), cursor) if ss.select(): #print "FOUND SPARQL MATCH" sparql_match = True ret = ss.make_graph() cursor.close() connect.commit() connect.close() return ret if not sparql_match: M = MyspaceScrape(uid=uid.rsplit('.rdf')[0]) M.run() if USE_SPARQL: M.insert_sparql(cursor) cursor.close() connect.commit() connect.close() return M.serialize() elif uid.endswith('.html'): # serve the html - THIS NEVER HAPPENS AND PRY NEVER WILL :p mh = Htmlify("http://dbtune.org/myspace/uid/"+uid.rsplit('.html')[0]) mh.parse_rdf() mh.get_all() return mh.html_head + mh.serialize_n3() + mh.get_available_as() +mh.html_tail else: raise cherrypy.HTTPRedirect(URL_BASE+'/uid/'+uid+'.rdf', 303)
def test_make_graph(self): cursor = self.connect.cursor() ss = SparqlSpace(self.uri, cursor) ss.select(GRAPH) print ss.make_graph()