Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubes
rqlcontroller
Commits
2ec46e035500
Commit
2b844713
authored
May 18, 2020
by
Guillaume Vandevelde
Browse files
[rql_schema_holder] Setup new views to request the schema or its hash
parent
2a4743846642
Changes
1
Hide whitespace changes
Inline
Side-by-side
cubicweb_rqlcontroller/views.py
View file @
2ec46e03
...
...
@@ -33,6 +33,7 @@ from cubicweb.web import RemoteCallFailed, DirectResponse
from
cubicweb.web.controller
import
Controller
from
cubicweb.web.views.urlrewrite
import
rgx_action
,
SchemaBasedRewriter
from
cubicweb
import
Binary
from
cubicweb_rqlcontroller.rql_schema_holder
import
RqlIOSchemaHolder
ARGRE
=
re
.
compile
(
r
'__r(?P<ref>\d+)$'
)
...
...
@@ -74,6 +75,18 @@ class match_request_content_type(ExpectedValuePredicate):
return
header
class
RqlIOSchemaController
(
Controller
,
RqlIOSchemaHolder
):
__regid__
=
'rqlio_schema'
__select__
=
match_http_method
(
'GET'
,
'HEAD'
)
def
publish
(
self
,
rset
=
None
):
self
.
_cw
.
set_content_type
(
'application/json'
)
self
.
_cw
.
add_header
(
'Etag'
,
self
.
get_schema_hash
)
return
json
.
dumps
(
self
.
get_schema
).
encode
(
self
.
_cw
.
encoding
)
class
RqlIOController
(
Controller
):
"""posted rql queries and arguments use the following pattern:
...
...
@@ -167,6 +180,8 @@ class RqlIOController(Controller):
class
RQLIORewriter
(
SchemaBasedRewriter
):
rules
=
[
(
re
.
compile
(
'/rqlio/schema'
),
rgx_action
(
controller
=
'rqlio_schema'
)),
(
re
.
compile
(
'/rqlio/(?P<version>.+)$'
),
rgx_action
(
controller
=
'rqlio'
,
formgroups
=
(
'version'
,)))
,
rgx_action
(
controller
=
'rqlio'
,
formgroups
=
(
'version'
,)))
]
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment