OK let me stop you there.
This is an issuse with Namespace
rdflib.Namespace decends from unicode which defines a func for title.
Things should work much better if you go with
DC['title'] rather than DC.title
I've asked the question of rdflib'ers here:
http://groups.google.com/group/rdflib-dev/browse_thread/thread/3b2279e691ec4d4d
This is a common problem in biblio land. Since I already modify the
rdflib Literal, maybe I should stick in my own Namespace def. I was
thinking that the rdf-python ecosystem would be better off if rdflib got
the fix. That codebase is moving forward again.
--
Phil
Well that's a mighty big question. The short answer is that I've
started work on rdfsSubject
(rdfsSubject as a subclass of rdfSubject) sorry about how visually
subtle the difference is but it should be intuitive that way.
As a fix to a previous ticket{23} I just posted a upgrade to
ClassInstances(). I have also just posted the first cut at
rdfsSubject. the "s" in rdfs refers to more schema info being handled.
rdfSubject will do as it does now...ignoring subclasses. rdfsSubject
will do some inferencing and it has a version of ClassInstances() that
should perform as you expected. (maybe this should be an optional arg
like ClassInstances(infer=True)
Some triplestores have an option of turning inferencing on (sesame)
and others provide no support. There is also the question as to how
much of the inferencing logic can be ported from or even better yet
plugged in from projects like pychinko[1].
I don't have the time to head down the long and complicated road of
doing all owl inferencing (should subProperties to show up now?).
Anyway, rdfalchemy is based on a practical philosophy. Academics have
experimented with this stuff long enough and your request seems pretty
reasonable so I've put it in.
Kind of....I haven't written the test cases but if you shoot me a
sample of your rdf, I'll work it into the unit tests.
--
Phil
I could have x == y return False but that would be a bad idea.
Equivalence does not necessarily require class equivelance. Compare
your example to:
>>> a = int('3')
>>> b = float('3')
>>> a == b
True
>>> 2/a
0
>>> 2/b
0.66666666666666663
In your example, the AcedemicArticle x and the Document y ARE the same
article .... just with different interfaces. And the interfaces
assigned them were done by the developer so he(or she) should know
what to expect. Developers will probably want to use this as a
feature rather than fear it as a bug.
(time and googlegroups will tell)
Re: what does x.rdf_type return, you could if you needed to, declare
a types descriptor:
class C(rdfSubject):
...
rdf_types = rdfMultiple(RDF.type)
Then x.rdf_types would return whatever (multiple) class type is in the
db.
The general reason for rdfsSubject will be for instances that will
match an rdf:type in the db to an appropriate python class. Something
like Zope interfaces but it might be home grown...stay tuned.
> IN the case, of rdfsSubject, it seems it should definitely
> privilege the subclass.
Not sure I am on point with you here but: any instance (x) of
rdfSubject or any decendent, when asked for x.rdf_type will return
rdf_type by looking in:
self.rdf_type (empty by default but you can set it e.g. in __init__)
self.__class__.rdf_type (where it usually is found)
the mro search for the rdf_type of a superclass
Standard (albeit not often used) python stuff there.
--
Phil