views.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:open-semantic-search-apps 作者: opensemanticsearch 项目源码 文件源码
def rdf(request):

    uri = request.GET['uri']

    g = Graph()

    annotations = Annotation.objects.filter(uri=uri)

    for annotation in annotations:

        if annotation.title:
            g.add( ( URIRef(annotation.uri), URIRef("http://localhost/metawiki/index.php/Special:URIResolver/Property-3ATitle"), Literal(annotation.title) ) )

        if annotation.notes:
            g.add( ( URIRef(annotation.uri), URIRef("http://localhost/metawiki/index.php/Special:URIResolver/Property-3ANotes"), Literal(annotation.notes) ) )

        for tag in annotation.tags.all():
            g.add( ( URIRef(annotation.uri), URIRef("http://localhost/metawiki/index.php/Special:URIResolver/Property-3ATag"), Literal(tag.prefLabel) ) )

    status = HttpResponse(g.serialize( format='xml' ) )
    status["Content-Type"] = "application/rdf+xml" 
    return status
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号