rdflib in webapps (MVC)

40 views
Skip to first unread message

farrar

unread,
Sep 16, 2009, 9:17:05 PM9/16/09
to rdflib-dev
Hi All

Are there any plans to provide a module that would facilitate the use
of rdflib with a web framework like, say Django? And I see that the
django-rdf code is no longer active.

If not, then does anyone have experience with creating a webapp from
scratch using rdflib to access the store?

thanks
Scott

Zach Dwiel

unread,
Sep 16, 2009, 10:24:51 PM9/16/09
to rdfli...@googlegroups.com
I've been interested in this for quite some time.  I've fleshed out a few ideas relating to this, though don't have anything production ready.  I'd love to share ideas and hear about what other people have done or are thinking about doing in this area.

zach

Gunnar Aastrand Grimnes

unread,
Sep 17, 2009, 2:32:06 AM9/17/09
to rdfli...@googlegroups.com
I've been using rdflib with web.py for years. It's not as much a
"webapp" as some thing I hacked together, but it works fairly well.

I use berkely DBs for storage, one for the whole site and one per
user. If I remember correctly I open them again for each request
served.

- Gunnar

2009/9/17 Zach Dwiel <zdw...@gmail.com>:
--
--
http://gromgull.net

Zach Dwiel

unread,
Sep 17, 2009, 10:28:57 AM9/17/09
to rdfli...@googlegroups.com
I had never seen web.py before, though I like it.  I have been using pylons with rdflib and other triple stores, but haven't really been using the MVC part of it.  I'm curious how you interface to the data.  for SQL databases there is SQLAlchemy.  Have you set anything similar up?

--
zach
dwiel.net

Gabriel Farrell

unread,
Sep 17, 2009, 11:14:46 AM9/17/09
to rdfli...@googlegroups.com
I've been investigating the use of rdflib with Django in Kochief [1].
I haven't set up a proper model framework yet, but for my initial
trials it's been easy enough to piggyback on the Postgresql or Sqlite
database the rest of the project is using.

I'd definitely be interested in further developments in this direction.


Gabriel

[1] http://kochief.googlecode.com -- see
http://code.google.com/p/kochief/source/browse/trunk/kochief/datastore/models.py
for some of the relevant code.

On Wed, Sep 16, 2009 at 9:17 PM, farrar <sofa...@gmail.com> wrote:
>

Joel Bender

unread,
Sep 17, 2009, 12:00:25 PM9/17/09
to rdfli...@googlegroups.com
Scott,


> Are there any plans to provide a module that would facilitate the use
> of rdflib with a web framework like, say Django? And I see that the
> django-rdf code is no longer active.

Are you interested in the same design direction, putting an rdf/sparql
layer on top of existing Django models?

Personally, I would like to see something like RDFAlchemy combined with
support for N3 queries inside genshi templates, but that's quite a bit
different framework.


Joel

Niklas Lindström

unread,
Sep 17, 2009, 12:41:07 PM9/17/09
to rdfli...@googlegroups.com
Zach, Joel, all,

On Thu, Sep 17, 2009 at 6:00 PM, Joel Bender <jj...@cornell.edu> wrote:
>
> Personally, I would like to see something like RDFAlchemy combined with
> support for N3 queries inside genshi templates, but that's quite a bit
> different framework.

You have (at least) two options for this. Either:

* RDFAlchemy <http://www.openvest.com/trac/wiki/RDFAlchemy>
* Oort <http://oort.to/>

You can find the OortPub-tutorial at
<http://oort.to/OortPub/tutorial.html>, which describes how to build a
read-only app with OortPub, using Oort for object views of data in an
rdflib Graph, and Paste and Genshi for the views.

I'm behind Oort. I must first warn that I have thought a bit about a
revamp of the stuff there, but nothing has emerged as a final design
yet. For instance, I've thought a lot about using a more Django:ish
webapp layer, with a thin integration possibly based on
<http://code.google.com/p/oort/wiki/SparqlTree> against any kind of
SPARQL-enabled triplestore.

.. And also to manage a "depot" (I've begun an OortDepot project with
no releases as of yet), which is basically viewing a tree of folders
and files as a coherent set of contexts ("entries"), which is supposed
to take care of timestamping and provenance, as well as proving
something resource-centric (somewhat Atom/AtomPub inspired) for
management (CRUD) of all content. The triplestore will be much more of
an optimization than primary storage in this scenario.

== Elaboration ==

My experiments with triplestores have showed that e.g. timestamp
sorting of large datasets isn't very feasible with many of today's
implementations unfortunately (my intent is in part to get someting
"GData"-like as an API for consumers who want something flatter and
simpler than the full power of SPARQL..).

(The "entries" here function as a context which represents a set of
statements related to one primary resource, but with it's own
timestamp, representation(s) and possibly related files such as images
etc. For the sake of management, and syndication of the repo. (I'm
thinking of modelling these as instances of either AtomOwl Entry or
SIOC Item.)).

If I find the time, I'll also look into pushing rdf as json into e.g.
CouchDB or MongoDB for these things (that json being either similar in
structure to the output of SparqlTrees, or something between that and
the crude triple form I've seen as rdf/json here and there) ..

(If you're interested in discussing this "depot" design, and ways to
implement it, I think it's out of scope for this list and I'd be happy
to continue discussions on e.g.
<http://groups.google.com/group/oort>.)

== Finally ==

One option is to build something "close to the metal" with Django, and
working on Atom feeds plus RDF representations out of the models
defined there. I'm very interested in Kochief that Gabriel mentioned
(as I've also noticed django-rdf seems inactive -- albeit perhaps we
could perhaps join efforts to invigorate that as well..). I'd also
like to mention the utility
<http://code.google.com/p/rdflib/source/browse/trunk/rdflib_tools/describer.py>
in current "rdflib_tools" which is a convenient way of creating RDF
from more "raw" data (e.g. converting django model instances to RDF).

Best regards,
Niklas

mhermans

unread,
Sep 17, 2009, 5:13:53 AM9/17/09
to rdflib-dev

> > On Wed, Sep 16, 2009 at 9:17 PM, farrar <sofar...@gmail.com> wrote:
> >> ... anyone have experience with creating a webapp from
> >> scratch using rdflib to access the store?


There are a few examples if you use RDFAlchemy[0] between rdflib and
your webframework. I have been inspired by Bruce D'Arcus, who uses
web.py + RDFAlchemy for his personal site, see github[1]. I have made
a prototype using Pylons + Genshi + RDFAlchemy[2].

I have not run into any showstoppers, the prototype is working, but I
have no idea if it scales (no time atm. to get it online). Basically,
once you have your model.py file defined, you can access your RDF-data
through python objects & properties, no different then using
SQLAlchemy or another ORM. I like it more, because you can then think
on the object level, not on the triple level.

An "out-of-the box" semantic webframework (python, but not rdflib) is
Cubicweb[3]. Seems very robust, but I have not tried it yet. An
alternative python/rdflib ORM, that seems to have more momentum atm.
is SURF [4], no idea how well it would fit in a webstack.

M

[0] http://www.openvest.com/trac/wiki/RDFAlchemy
[1] http://github.com/bdarcus/mysite
[2] http://github.com/mhermans/serialservice
[3] http://www.cubicweb.org/
[4] http://code.google.com/p/surfrdf/

Chimezie Ogbuji

unread,
Sep 18, 2009, 9:27:12 AM9/18/09
to rdfli...@googlegroups.com
It's probably also worth mentioning (recently development) telescope
which I use to generate SPARQL expressions from RIF rules with
negative conditions:

http://bitbucket.org/exogen/telescope/overview/
http://bitbucket.org/exogen/telescope/wiki/SPARQLBuilder
http://bitbucket.org/exogen/telescope/src/tip/tests/test_mapper.py

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