This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

django-4store is a small Django application that makes developing apps with the 4Store RDF database easier.

Installation

django-4store is on PyPi for easy_install or buildout:

$ easy_install django-4store

Alternatively, clone the repository and place it either in your Django project or within your $PYTHONPATH:

$ git clone git://github.com/66laps/django-4store.git

Configuration

Edit your settings.py and add fourstore to the end of INSTALLED_APPS.

You must also add two additional settings to settings.py:

FOURSTORE_KBNAME = "demo"  # Name of 4store knowledge base
FOURSTORE_PORT = 6667      # Port for 4store HTTP server

It is recommended (but not required) that you also set a constant to the SPARQL endpoint at the same time:

SPARQL_ENDPOINT = "http://localhost:6667/sparql/"

Code that depends on this endpoint URL will continue to work during testing (see Test Cases.)

Management Commands

Two management commands are provided that wrap the standard 4s-* commands for convenience.

The first, 4store-import will create and import the specified files into the 4store knowledge base (in settings.py):

$ python manage.py 4store-import rdf/card.rdf rdf/myself.n3

The flag --recursive can be specified to recursively add any RDF files in a directory.

Note that importing data will overwrite any existing content in the knowledge base.

The second command, 4store will start the HTTP server on the port specified in settings.py:

$ python manage.py 4store
...

Test Cases

A subclass of django.test.Testcase is included. This provides a mechanism for starting an isolated 4store server and automatically importing test fixtures.

For example, the following test case can be used to test any 4store dependant code:

from django.conf import settings
from HTTP4Store import HTTP4Store

from fourstore.test import Base4StoreTest

class MySemanticTestCase(Base4StoreTest):
    kbfixtures = ["card.rdf", "someone.n3"]

    def test_something(self):
        store = HTTP4Store(settings.SPARQL_ENDPOINT)
        response = store.sparql("SELECT * WHERE { ?s ?p ?o . } ")
        self.assertEquals(..., response)

Test fixtures should be placed within the fixtures directory of the app under testing (note the class variable is kbfixtures).

The Django setting attribute settings.SPARQL_ENDPOINT is automatically updated to the current endpoint URL.

The server is reinitialised between tests and its operation is dependant on setUp and tearDown. If you need to override these methods, make sure that you still call the parent implementations:

class MySemanticTestCase(Base4StoreTest):
    ...
    def setUp(self):
         Base4StoreTest.setUp(self)
         // do something

    def tearDown(self):
        Base4StoreTest.tearDown(self)
        // do something

Views

Cross-site HTTP Requests are typically blocked by web browsers for many historically well documented security reasons. These restrictions prevent web applications from communicating directly with SPARQL endpoints.

django-4store provides a solution to this problem. The view fourstore.views.sparql_proxy relays all HTTP requests it receives to a specified endpoint (given in urls.py).

For example, to communicate with Dbpedia configure urls.py as follows:

from django.conf.urls.defaults import url, patterns

urlpatterns = patterns('fourstore.views',
    url(r"^sparql/$", "sparql_proxy", {"sparql_endpoint": "http://www.dbpedia.org/sparql/"}),
)

Any requests made to http://www.yourdjangoapp.com/sparql/ are now automatically relayed to http://www.dbpedia.org/sparql/ and the response transparent sent back to the originating browser.

Note that in accordance with the SPARQL Protocol all requests must have a Content-Type of application/x-www-form-urlencoded.

Test Suite

A test suite for django-4store is included:

$ python manage.py test fourstore

License

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Release History

Release History

0.3

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-4store-0.3.tar.gz (11.7 kB) Copy SHA256 Checksum SHA256 Source Jan 26, 2011

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting