[redland-dev] Problem: removing triple without specifying
triple's object
Dave Beckett
dave.beckett at bristol.ac.uk
Tue Jul 19 10:09:58 BST 2005
On Tue, 2005-07-19 at 10:37 +0200, Roman Bischoff wrote:
> Hi,
>
> I want to do CRUD of RDF statements via HTML forms and CGI using Redland's
> Python bindings. The 'Create' and 'Read' operations work quite well so far.
>
> For updating the object node of a certain RDF triple (defined by
> subject_node, predicate_node and context_node), it seems that I need first
> to delete the existing RDF triple, and add afterwards a new triple.
> (otherwise there are multiple RDF triples with the same subject, predicate
> and different object and same context in the triplestore)
Yeah, you do need to do that. If you can think of an alternate update
method, what would it be? In mozilla I think they have an updateObject
method something like:
model.updateObject(subject, predicate, oldObject, newObject)
but maybe an updateStatement one would work better for redland:
model.updateStatement(oldSt, newSt)
(although how atomic that could be made inside redland is another
matter)
> So far I couldn't remove RDF statements from the model when using "None" as
> object node. (using the object's literal value works)
I'm surprised you can store None at all.
> I intend to use "None" as object node, because I want to remove (i.e.
> update) this type of statement before adding a now one, regardless of the
> currently existing (literal) value for the object node.
If this is the case, then I'll add a check to prevent this as None is a
python concept and not storable in redland (or portable, usable between
languages).
> my two questions:
>
> 1) is it generally possible to use "None" as object node when deleting
> statements from a model?
No.
> 2) how to do it in Python?
>
> delst = RDF.Statement(subj_node, predicate_node, None)
> del rdfmodel[delst, context_node]
>
> ==> doesn't work.
>
> delst = RDF.Statement(subj_node, predicate_node, "0123456")
> del rdfmodel[delst, context_node]
>
> ==> works fine.
Yes, you must give all parts of a triple to store and retrieve it.
> (I use: Python 2.4.1, Debian 1:3.3.5-8ubuntu2, librdf 1.0.2-1ubuntu1)
>
> Thanks for any help
>
> Regards,
> Roman
Dave
More information about the redland-dev
mailing list