retrieving object based on its URI using RDFAlchemy and rdflib
Question
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
Solution
I guess should be something like:
b = Book(URIRef(uri))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow