跳转到主要内容

基于奥尔特,支持WSGI的用于创建RDF驱动的Web应用的工具包。

项目描述

奥尔特普布是一个用于创建RDF-驱动的WSGI兼容的Web应用的工具包。

这个项目的目的是通过使用一些声明式Python编程,使创建RDF图的Web视图变得容易。

奥尔特普布使用了RDFLibPasteGenshi来完成主要的任务。

RDF到对象的工具来自单独发布的Oort核心包。

概述

主要包是

oort.sitebase

包含用于声明性定义显示的类,用于匹配资源和渲染特定的输出(HTML、JSON等)。通过定义方面,所选资源的类型(或超类型)被映射到特定的RdfQuery和相关模板。

一个或多个显示被放在资源查看器的上下文中,它成为一个准备在WSGI环境中挂载的WSGI应用。

如何?

大量的RDF数据,如

<site/main> a :SiteNode;
    dc:title "Main Page"@en, "Huvudsida"@sv;
    dc:altTitle "Main", "Hem"@sv;
    :relations (
        <site/faq>
        <site/about>
    );
    :nodeContent '''<h1 xml:lang="en">Welcome</h1>'''^^rdfs:XMLLiteral,
                 '''<h1 xml:lang="sv">V&#195;&#164;lkommen</h1>'''^^rdfs:XMLLiteral .

<persons/someone> a foaf:Person;
    foaf:name "Some One";
    foaf:knows <otherone> .

一些RdfQuery

from oort.rdfview import *
SITE = Namespace("http://example.org/ns/2007/website#")

class Titled(RdfQuery):
    title = localized(DC)
    altTitle = localized(DC.alternative)

class SiteNode(Titled):
    relations = collection(SITE) >> Titled
    nodeContent = localized_xml(SITE)

class Person(RdfQuery):
    name = one(FOAF)
    knows = each(FOAF) >> 'Person'

和一个Web应用

from oort.sitebase import *
from myapp import queries
from myapp.ns import SITE

class ExampleViewer(ResourceViewer):

    resourceBase = "http://example.org/oort/"
    langOrder = 'en', 'sv'

    class PlainWebDisplay(Display):
        name = "main"
        default = True
        outputMethod = 'xhtml'
        outputEncoding  = 'iso-8859-1'
        templateBase = "view/mainweb"
        globalQueries = {'languages': queries.sitelabels }
        aspects = [
                Aspect(SITE.SiteNode, "sitenode.xhtml",
                        {'node': queries.SiteNode}) ,
                Aspect(FOAF.Person, "person.xhtml",
                        {'person': queries.Person}) ,
                Aspect(RDFS.Resource, "not_found.xhtml")
            ]

    class JsonDisplay(Display):
        name = "json"
        contentType = 'application/x-javascript'
        aspects = [
                JsonAspect(SITE.SiteNode, {'node': queries.SiteNode})
            ]

但是等等,还有更多...

Paste!

使WSGI运行平稳。ResourceViewers在其构造函数中接受RDFLib Graph 实例,并成为符合规范的调用者。

要快速开始,请运行

$ paster create -t oort_app
... fill in desired values in the dialogue
$ cd myapp/
$ vim # edit and test..
$ chmod u+x webapp.ini
$ ./webapp.ini

为什么?

因为RDF是一种强大的技术,可能彻底改变信息处理和共享的方式。Python和WSGI是构建处理此类数据的应用程序时使用的典范技术。

项目详情


下载文件

下载您平台对应的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源代码发行版

OortPub-0.1.tar.gz (13.3 kB 查看哈希值)

上传时间 源代码

构建发行版

OortPub-0.1-py2.5.egg (32.6 kB 查看哈希值)

上传时间 源代码

由以下支持