author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Mon, 16 Nov 2009 09:37:06 +0100 | |
branch | stable |
changeset 3853 | e8af6f586882 |
parent 3689 | deb13e88e037 |
child 3720 | 5376aaadd16b |
child 3953 | 19aefd78f61b |
permissions | -rw-r--r-- |
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
1 |
"""SPARQL integration |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
2 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
3 |
:organization: Logilab |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
4 |
:copyright: 2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
6 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
7 |
""" |
2426
0209d9bc45a8
possibility to choose results format, set a nicer file name on sparqlxml view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2424
diff
changeset
|
8 |
v__docformat__ = "restructuredtext en" |
2424
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
9 |
|
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
10 |
import rql |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
11 |
from yams import xy |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
12 |
|
2424
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
13 |
from lxml import etree |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
14 |
from lxml.builder import E |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
15 |
|
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
16 |
from cubicweb.view import StartupView, AnyRsetView |
2426
0209d9bc45a8
possibility to choose results format, set a nicer file name on sparqlxml view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2424
diff
changeset
|
17 |
from cubicweb.web import Redirect, form, formfields, formwidgets as fwdgs |
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
18 |
from cubicweb.web.views import forms, urlrewrite |
2529
736893a990c4
make fyzz/spa2rql a recommends only
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2444
diff
changeset
|
19 |
try: |
736893a990c4
make fyzz/spa2rql a recommends only
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2444
diff
changeset
|
20 |
from cubicweb.spa2rql import Sparql2rqlTranslator |
736893a990c4
make fyzz/spa2rql a recommends only
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2444
diff
changeset
|
21 |
except ImportError: |
736893a990c4
make fyzz/spa2rql a recommends only
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2444
diff
changeset
|
22 |
# fyzz not available (only a recommends) |
736893a990c4
make fyzz/spa2rql a recommends only
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2444
diff
changeset
|
23 |
Sparql2rqlTranslator = None |
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
24 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
25 |
class SparqlForm(forms.FieldsForm): |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
26 |
id = 'sparql' |
2444
4e61d9e4befb
[cleanup] fix typo
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2426
diff
changeset
|
27 |
sparql = formfields.StringField(help=_('type here a sparql query')) |
2426
0209d9bc45a8
possibility to choose results format, set a nicer file name on sparqlxml view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2424
diff
changeset
|
28 |
resultvid = formfields.StringField(choices=((_('table'), 'table'), |
0209d9bc45a8
possibility to choose results format, set a nicer file name on sparqlxml view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2424
diff
changeset
|
29 |
(_('sparql xml'), 'sparqlxml')), |
0209d9bc45a8
possibility to choose results format, set a nicer file name on sparqlxml view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2424
diff
changeset
|
30 |
widget=fwdgs.Radio, |
0209d9bc45a8
possibility to choose results format, set a nicer file name on sparqlxml view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2424
diff
changeset
|
31 |
initial='table') |
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
32 |
form_buttons = [fwdgs.SubmitButton()] |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
33 |
@property |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
34 |
def action(self): |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
35 |
return self.req.url() |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
36 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
37 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
38 |
class SparqlFormView(form.FormViewMixIn, StartupView): |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
39 |
id = 'sparql' |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
40 |
def call(self): |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
41 |
form = self.vreg.select('forms', 'sparql', self.req) |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
42 |
self.w(form.form_render()) |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
43 |
sparql = self.req.form.get('sparql') |
2426
0209d9bc45a8
possibility to choose results format, set a nicer file name on sparqlxml view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2424
diff
changeset
|
44 |
vid = self.req.form.get('resultvid', 'table') |
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
45 |
if sparql: |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
46 |
try: |
2426
0209d9bc45a8
possibility to choose results format, set a nicer file name on sparqlxml view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2424
diff
changeset
|
47 |
qinfo = Sparql2rqlTranslator(self.schema).translate(sparql) |
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
48 |
except rql.TypeResolverException, ex: |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
49 |
self.w(self.req._('can not resolve entity types:') + u' ' + unicode('ex')) |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
50 |
except UnsupportedQuery: |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
51 |
self.w(self.req._('we are not yet ready to handle this query')) |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
52 |
except xy.UnsupportedVocabulary, ex: |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
53 |
self.w(self.req._('unknown vocabulary:') + u' ' + unicode('ex')) |
2426
0209d9bc45a8
possibility to choose results format, set a nicer file name on sparqlxml view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2424
diff
changeset
|
54 |
if vid == 'sparqlxml': |
0209d9bc45a8
possibility to choose results format, set a nicer file name on sparqlxml view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2424
diff
changeset
|
55 |
url = self.build_url('view', rql=qinfo.finalize(), vid=vid) |
0209d9bc45a8
possibility to choose results format, set a nicer file name on sparqlxml view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2424
diff
changeset
|
56 |
raise Redirect(url) |
0209d9bc45a8
possibility to choose results format, set a nicer file name on sparqlxml view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2424
diff
changeset
|
57 |
rset = self.req.execute(qinfo.finalize()) |
0209d9bc45a8
possibility to choose results format, set a nicer file name on sparqlxml view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2424
diff
changeset
|
58 |
self.wview(vid, rset, 'null') |
0209d9bc45a8
possibility to choose results format, set a nicer file name on sparqlxml view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2424
diff
changeset
|
59 |
|
2424
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
60 |
|
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
61 |
## sparql resultset views ##################################################### |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
62 |
|
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
63 |
YAMS_XMLSCHEMA_MAPPING = { |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
64 |
'String': 'string', |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
65 |
'Int': 'integer', |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
66 |
'Float': 'float', |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
67 |
'Boolean': 'boolean', |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
68 |
'Datetime': 'dateTime', |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
69 |
'Date': 'date', |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
70 |
'Time': 'time', |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
71 |
# XXX the following types don't have direct mapping |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
72 |
'Decimal': 'string', |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
73 |
'Interval': 'duration', |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
74 |
'Password': 'string', |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
75 |
'Bytes': 'base64Binary', |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
76 |
} |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
77 |
|
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
78 |
def xmlschema(yamstype): |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
79 |
return 'http://www.w3.org/2001/XMLSchema#%s' % YAMS_XMLSCHEMA_MAPPING[yamstype] |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
80 |
|
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
81 |
class SparqlResultXmlView(AnyRsetView): |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
82 |
"""The spec can be found here: http://www.w3.org/TR/rdf-sparql-XMLres/ |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
83 |
""" |
2426
0209d9bc45a8
possibility to choose results format, set a nicer file name on sparqlxml view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2424
diff
changeset
|
84 |
id = 'sparqlxml' |
2424
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
85 |
content_type = 'application/sparql-results+xml' |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
86 |
templatable = False |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
87 |
|
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
88 |
def call(self): |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
89 |
# XXX handle UNION |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
90 |
rqlst = self.rset.syntax_tree().children[0] |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
91 |
varnames = [var.name for var in rqlst.selection] |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
92 |
results = E.results() |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
93 |
for rowidx in xrange(len(self.rset)): |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
94 |
result = E.result() |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
95 |
for colidx, varname in enumerate(varnames): |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
96 |
result.append(self.cell_binding(rowidx, colidx, varname)) |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
97 |
results.append(result) |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
98 |
sparql = E.sparql(E.head(*(E.variable(name=name) for name in varnames)), |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
99 |
results) |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
100 |
self.w(u'<?xml version="1.0"?>\n') |
2426
0209d9bc45a8
possibility to choose results format, set a nicer file name on sparqlxml view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2424
diff
changeset
|
101 |
self.w(etree.tostring(sparql, encoding=unicode, pretty_print=True)) |
2424
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
102 |
|
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
103 |
def cell_binding(self, row, col, varname): |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
104 |
celltype = self.rset.description[row][col] |
3689
deb13e88e037
follow yams 0.25 api changes to improve performance
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2529
diff
changeset
|
105 |
if self.schema.eschema(celltype).final: |
2424
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
106 |
cellcontent = self.view('cell', self.rset, row=row, col=col) |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
107 |
return E.binding(E.literal(cellcontent, |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
108 |
datatype=xmlschema(celltype)), |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
109 |
name=varname) |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
110 |
else: |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
111 |
entity = self.entity(row, col) |
70f85df651a5
simple implementation of sparql XML resultset view
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2422
diff
changeset
|
112 |
return E.binding(E.uri(entity.absolute_url()), name=varname) |
2426
0209d9bc45a8
possibility to choose results format, set a nicer file name on sparqlxml view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2424
diff
changeset
|
113 |
|
0209d9bc45a8
possibility to choose results format, set a nicer file name on sparqlxml view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2424
diff
changeset
|
114 |
def set_request_content_type(self): |
0209d9bc45a8
possibility to choose results format, set a nicer file name on sparqlxml view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2424
diff
changeset
|
115 |
"""overriden to set the correct filetype and filename""" |
0209d9bc45a8
possibility to choose results format, set a nicer file name on sparqlxml view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2424
diff
changeset
|
116 |
self.req.set_content_type(self.content_type, |
0209d9bc45a8
possibility to choose results format, set a nicer file name on sparqlxml view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2424
diff
changeset
|
117 |
filename='sparql.xml', |
0209d9bc45a8
possibility to choose results format, set a nicer file name on sparqlxml view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2424
diff
changeset
|
118 |
encoding=self.req.encoding) |
2529
736893a990c4
make fyzz/spa2rql a recommends only
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2444
diff
changeset
|
119 |
|
736893a990c4
make fyzz/spa2rql a recommends only
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2444
diff
changeset
|
120 |
def registration_callback(vreg): |
736893a990c4
make fyzz/spa2rql a recommends only
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2444
diff
changeset
|
121 |
if Sparql2rqlTranslator is not None: |
736893a990c4
make fyzz/spa2rql a recommends only
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2444
diff
changeset
|
122 |
vreg.register_all(globals().values(), __name__) |