-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-organize RestAPI structure. Add data table
- Loading branch information
Showing
12 changed files
with
167 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
""" RestAPI | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<configure | ||
xmlns="http://namespaces.zope.org/zope" | ||
xmlns:plone="http://namespaces.plone.org/plone"> | ||
|
||
</configure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,5 @@ | ||
<configure | ||
xmlns="http://namespaces.zope.org/zope" | ||
xmlns:plone="http://namespaces.plone.org/plone"> | ||
|
||
<include package="plone.restapi" /> | ||
|
||
<plone:service | ||
method="GET" | ||
name="@dataprovenance" | ||
for="Products.CMFCore.interfaces.ISiteRoot" | ||
factory=".get.DataProvenance" | ||
permission="zope2.View" | ||
/> | ||
|
||
<plone:service | ||
method="GET" | ||
name="@dataprovenance" | ||
for="Products.CMFCore.interfaces.IContentish" | ||
factory=".get.Get" | ||
permission="zope2.View" | ||
/> | ||
|
||
<adapter factory=".get.DataProvenance" name="dataprovenance" /> | ||
|
||
<plone:service | ||
method="POST" | ||
name="@dataprovenance" | ||
for="Products.CMFCore.interfaces.ISiteRoot" | ||
factory=".post.DataProvenance" | ||
permission="eea.app.visualization.configure" | ||
/> | ||
|
||
<plone:service | ||
method="POST" | ||
name="@dataprovenance" | ||
for="Products.CMFCore.interfaces.IContentish" | ||
factory=".post.Post" | ||
permission="eea.app.visualization.configure" | ||
/> | ||
|
||
</configure> | ||
<configure xmlns="http://namespaces.zope.org/zope"> | ||
<include package="plone.restapi" /> | ||
<include package=".charts" /> | ||
<include package=".data" /> | ||
</configure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
""" RestAPI | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<configure xmlns="http://namespaces.zope.org/zope"> | ||
<include package=".table" /> | ||
<include package=".provenance" /> | ||
</configure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
""" RestAPI | ||
""" |
45 changes: 45 additions & 0 deletions
45
eea/app/visualization/restapi/data/provenance/configure.zcml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<configure | ||
xmlns="http://namespaces.zope.org/zope" | ||
xmlns:plone="http://namespaces.plone.org/plone"> | ||
|
||
<include package="plone.restapi" /> | ||
|
||
<!-- Data Provenance --> | ||
|
||
<plone:service | ||
method="GET" | ||
name="@provenances" | ||
for="Products.CMFCore.interfaces.ISiteRoot" | ||
factory=".get.DataProvenance" | ||
permission="zope2.View" | ||
/> | ||
|
||
<plone:service | ||
method="GET" | ||
name="@provenances" | ||
for="Products.CMFCore.interfaces.IContentish" | ||
factory=".get.Get" | ||
permission="zope2.View" | ||
/> | ||
|
||
<adapter factory=".get.DataProvenance" name="provenances" /> | ||
|
||
<!-- TODO: #123935 - Unify IDataProvenance with IMultiDataProvenance | ||
<plone:service | ||
method="POST" | ||
name="@provenances" | ||
for="Products.CMFCore.interfaces.ISiteRoot" | ||
factory=".post.DataProvenance" | ||
permission="eea.app.visualization.configure" | ||
/> | ||
<plone:service | ||
method="POST" | ||
name="@provenances" | ||
for="Products.CMFCore.interfaces.IContentish" | ||
factory=".post.Post" | ||
permission="eea.app.visualization.configure" | ||
/> | ||
--> | ||
|
||
</configure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
""" RestAPI | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<configure | ||
xmlns="http://namespaces.zope.org/zope" | ||
xmlns:plone="http://namespaces.plone.org/plone"> | ||
|
||
<plone:service | ||
method="GET" | ||
name="@table" | ||
for="Products.CMFCore.interfaces.ISiteRoot" | ||
factory=".get.DataProvenance" | ||
permission="zope2.View" | ||
/> | ||
|
||
<plone:service | ||
method="GET" | ||
name="@table" | ||
for="Products.CMFCore.interfaces.IContentish" | ||
factory=".get.Get" | ||
permission="zope2.View" | ||
/> | ||
|
||
<adapter factory=".get.DataTable" name="table" /> | ||
|
||
</configure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
""" RestAPI GET enpoints | ||
""" | ||
from zope.publisher.interfaces import IPublishTraverse | ||
from zope.interface import implementer | ||
from zope.interface import Interface | ||
from zope.component import adapter, queryMultiAdapter | ||
from plone.restapi.services import Service | ||
from plone.restapi.serializer.converters import json_compatible | ||
from plone.restapi.interfaces import IExpandableElement | ||
from Products.CMFPlone.interfaces import IPloneSiteRoot | ||
|
||
|
||
@implementer(IExpandableElement) | ||
@adapter(Interface, Interface) | ||
class DataTable(object): | ||
""" Get data table | ||
""" | ||
def __init__(self, context, request): | ||
self.context = context | ||
self.request = request | ||
|
||
def __call__(self, expand=False): | ||
result = {"table": { | ||
"@id": "{}/@table".format(self.context.absolute_url()), | ||
}} | ||
|
||
if not expand: | ||
return result | ||
|
||
if IPloneSiteRoot.providedBy(self.context): | ||
return result | ||
|
||
view = queryMultiAdapter(( | ||
self.context, self.request), | ||
name='download.table' | ||
) | ||
|
||
if not view: | ||
return result | ||
|
||
result['table'].update(json_compatible(view.data)) | ||
return result | ||
|
||
|
||
@implementer(IPublishTraverse) | ||
class Get(Service): | ||
"""GET""" | ||
|
||
def reply(self): | ||
"""Reply""" | ||
info = DataTable(self.context, self.request) | ||
return info(expand=True)["table"] |