get_by resUri?

8 views
Skip to first unread message

Bruce D'Arcus

unread,
May 30, 2008, 5:24:25 PM5/30/08
to rdfalchemy-dev
I'm looking to grab a rdfSubject object by its uri. How best to do
that (my attempt to do rdfSubject.get_by(resUri=uri) results in an
error ...

Bruce

Phil

unread,
May 31, 2008, 12:38:17 AM5/31/08
to rdfalchemy-dev
On May 30, 3:24 pm, "Bruce D'Arcus" <bdarcus.li...@gmail.com> wrote:
> I'm looking to grab a rdfSubject object by its uri. How best to do that

Short answer: If you already have a uri (i.e. the correct class) ...

a = rdfSubject(uri)

If you only have a string:

a = rdfSubject(URIRef(str))
or
a= rdfSubject('<http://my.example.com/schema/project#thing1234>')

you can check out

help(rdfSubject)

I try pretty hard to make the __init__ do the right thing.
--
Phil




Bruce D'Arcus

unread,
May 31, 2008, 2:49:43 AM5/31/08
to rdfalchemy-dev


On May 31, 12:38 am, Phil <philip.coo...@openvest.com> wrote:

> Short answer: If you already have a uri (i.e. the correct class) ...
>
> a = rdfSubject(uri)
>
> If you only have a string:
>
> a = rdfSubject(URIRef(str))
> or
> a= rdfSubject('<http://my.example.com/schema/project#thing1234>')

So one uses the same command to find an rdfSubject object as one does
to create one? I'm fairly new to Python; would that be a standard
Pythonic approach?

Bruce

Phil

unread,
May 31, 2008, 9:06:09 AM5/31/08
to rdfalchemy-dev
On May 31, 12:49 am, "Bruce D'Arcus" <bdarcus.li...@gmail.com> wrote:
> On May 31, 12:38 am, Phil <philip.coo...@openvest.com> wrote:
>
> > Short answer: ...
>
> > a = rdfSubject(uri)
>
> So one uses the same command to find an rdfSubject object as one does
> to create one? I'm fairly new to Python; would that be a standard
> Pythonic approach?

I thinks so but I would almost call the behavior more rdf-ish than
pythonic.
A URIRef is the name of something. RDF open-world assumptions say
that you have named the subject but triples relating to it may or may
not exist in your triplestore, they could be in some other
triplestore (Bibliography's are great candidates for being published
at SPARQL entpoints IMHO).

a = rdfSubject(MYNS.item47)

does not add any statements to the triplestore but it they are there

a._ppo()

will then reveal them interactively.

b = Document(MYNS.item47)

will add at least one triple to the triplestore if none exists since
you have asserted something about the URI. That triple is:

(MYNS.item47, RDF.type, BIBO.Document)

In rdf, the uriref is the primary key to the ONLY table that exists
(triples). If you have the URI you have your subject.
It is not "bound" to your code or your database as a key in a program
or a relational database might be.

One of the nice advantages of RDF in general.

--
Phil
Reply all
Reply to author
Forward
0 new messages