3

我正在使用 RDFAlchemy 和 rdflib 图作为数据源,即 rdfalchemy.rdfSubject.db。如果我有它的 uri,我如何让 rdfalchemy 映射一个对象?使用 uri 调用构造函数会创建一个对象,但不会从图中检索其他属性的值。使用 get_by(resUri='http://...') 会产生 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
4

1 回答 1

3

我想应该是这样的:

b = Book(URIRef(uri)) 
于 2012-05-22T18:13:39.317 回答