3

I am using RDFAlchemy and rdflib graph for the source of the data, i.e. rdfalchemy.rdfSubject.db. How can I have rdfalchemy map an object if I have its uri? calling the constructor with the uri creates an object but doesn't retrieve values of other properties from the graph. Using get_by(resUri='http://...') yields an AttributeError

class Book(rdfAlchemy.rdfSubject):
  rdf_type = BIBO.Book
  isbn = rdfalchemy.rdfSingle(BIBO.isbn10)
Book.get_by(resUri='') # AttributeError
b = Book(uri) #a book identified with uri exists in the data 
b.title #empty string
fadmaa
  • 3,067
  • 3
  • 18
  • 14

1 Answers1

3

I guess should be something like:

b = Book(URIRef(uri)) 
wikier
  • 2,517
  • 2
  • 26
  • 39
  • +1 Too bad it was never accepted. This was (and still is) the right answer. Note: I'm the creator of rdfAlchemy. – Phil Cooper Jun 23 '12 at 20:04