Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Klaus Wölfel
slapos.core
Commits
8db76f83
Commit
8db76f83
authored
Apr 11, 2016
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_hypermedia: migrate bt to new format
parent
673cba0a
Changes
25
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
535 additions
and
587 deletions
+535
-587
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Base_getHateoasMaster.py
...m/portal_skins/slapos_hypermedia/Base_getHateoasMaster.py
+37
-0
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Base_getHateoasMaster.xml
.../portal_skins/slapos_hypermedia/Base_getHateoasMaster.xml
+0
-41
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Computer_getHateoasSoftwareInstallationList.py
...hypermedia/Computer_getHateoasSoftwareInstallationList.py
+43
-0
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Computer_getHateoasSoftwareInstallationList.xml
...ypermedia/Computer_getHateoasSoftwareInstallationList.xml
+0
-47
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/HostingSubscription_getHateoasInstanceList.py
..._hypermedia/HostingSubscription_getHateoasInstanceList.py
+42
-0
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/HostingSubscription_getHateoasInstanceList.xml
...hypermedia/HostingSubscription_getHateoasInstanceList.xml
+0
-46
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/HostingSubscription_getHateoasRootSoftwareInstance.py
...dia/HostingSubscription_getHateoasRootSoftwareInstance.py
+42
-0
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/HostingSubscription_getHateoasRootSoftwareInstance.xml
...ia/HostingSubscription_getHateoasRootSoftwareInstance.xml
+0
-46
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Instance_getHateoasInformation.py
...skins/slapos_hypermedia/Instance_getHateoasInformation.py
+49
-0
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Instance_getHateoasInformation.xml
...kins/slapos_hypermedia/Instance_getHateoasInformation.xml
+0
-53
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Instance_getHateoasNews.py
...portal_skins/slapos_hypermedia/Instance_getHateoasNews.py
+47
-0
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Instance_getHateoasNews.xml
...ortal_skins/slapos_hypermedia/Instance_getHateoasNews.xml
+0
-51
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Instance_getHateoasRelatedHostingSubscription.py
...permedia/Instance_getHateoasRelatedHostingSubscription.py
+42
-0
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Instance_getHateoasRelatedHostingSubscription.xml
...ermedia/Instance_getHateoasRelatedHostingSubscription.xml
+0
-46
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Person_getHateoasComputerList.py
..._skins/slapos_hypermedia/Person_getHateoasComputerList.py
+43
-0
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Person_getHateoasComputerList.xml
...skins/slapos_hypermedia/Person_getHateoasComputerList.xml
+0
-47
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Person_getHateoasHostingSubscriptionList.py
...os_hypermedia/Person_getHateoasHostingSubscriptionList.py
+44
-0
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Person_getHateoasHostingSubscriptionList.xml
...s_hypermedia/Person_getHateoasHostingSubscriptionList.xml
+0
-48
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Person_requestHateoasHostingSubscription.py
...os_hypermedia/Person_requestHateoasHostingSubscription.py
+53
-0
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Person_requestHateoasHostingSubscription.xml
...s_hypermedia/Person_requestHateoasHostingSubscription.xml
+0
-61
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/SoftwareInstallation_getHateoasInformation.py
..._hypermedia/SoftwareInstallation_getHateoasInformation.py
+44
-0
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/SoftwareInstallation_getHateoasInformation.xml
...hypermedia/SoftwareInstallation_getHateoasInformation.xml
+0
-48
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/SoftwareInstallation_getHateoasNews.py
.../slapos_hypermedia/SoftwareInstallation_getHateoasNews.py
+48
-0
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/SoftwareInstallation_getHateoasNews.xml
...slapos_hypermedia/SoftwareInstallation_getHateoasNews.xml
+0
-52
master/bt5/slapos_hypermedia/bt/dependency_list
master/bt5/slapos_hypermedia/bt/dependency_list
+1
-1
No files found.
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Base_getHateoasMaster.py
0 → 100644
View file @
8db76f83
from
zExceptions
import
Unauthorized
from
AccessControl
import
getSecurityManager
if
REQUEST
is
None
:
raise
Unauthorized
response
=
REQUEST
.
RESPONSE
mime_type
=
'application/hal+json'
if
REQUEST
.
other
[
'method'
]
!=
"GET"
:
response
.
setStatus
(
405
)
return
""
elif
mime_type
!=
context
.
Base_handleAcceptHeader
([
mime_type
]):
response
.
setStatus
(
406
)
return
""
import
json
result_dict
=
json
.
loads
(
context
.
ERP5Document_getHateoas
(
REQUEST
))
portal
=
context
.
getPortalObject
()
person
=
portal
.
ERP5Site_getAuthenticatedMemberPersonValue
()
if
person
is
not
None
:
result_dict
[
'_links'
][
'me'
]
=
{
"href"
:
"urn:jio:get:%s"
%
person
.
getRelativeUrl
(),
}
else
:
user
=
str
(
portal
.
portal_membership
.
getAuthenticatedMember
())
if
user
!=
"Anonymous User"
:
user_document
=
context
.
ERP5Site_getUserDocument
(
user
)
result_dict
[
'_links'
][
'me'
]
=
{
'href'
:
'urn:jio:get:%s'
%
user_document
.
getRelativeUrl
(),
}
response
.
setHeader
(
'Content-Type'
,
mime_type
)
return
json
.
dumps
(
result_dict
,
indent
=
2
)
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Base_getHateoasMaster.xml
View file @
8db76f83
...
@@ -48,47 +48,6 @@
...
@@ -48,47 +48,6 @@
</object>
</object>
</value>
</value>
</item>
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
from zExceptions import Unauthorized\n
from AccessControl import getSecurityManager\n
\n
if REQUEST is None:\n
raise Unauthorized\n
\n
response = REQUEST.RESPONSE\n
mime_type = \'application/hal+json\'\n
\n
if REQUEST.other[\'method\'] != "GET":\n
response.setStatus(405)\n
return ""\n
elif mime_type != context.Base_handleAcceptHeader([mime_type]):\n
response.setStatus(406)\n
return ""\n
\n
import json\n
result_dict = json.loads(context.ERP5Document_getHateoas(REQUEST))\n
\n
portal = context.getPortalObject()\n
\n
person = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
if person is not None:\n
result_dict[\'_links\'][\'me\'] = {\n
"href": "urn:jio:get:%s" % person.getRelativeUrl(),\n
}\n
\n
else:\n
user = str(portal.portal_membership.getAuthenticatedMember())\n
if user != "Anonymous User":\n
user_document = context.ERP5Site_getUserDocument(user)\n
result_dict[\'_links\'][\'me\'] = {\n
\'href\': \'urn:jio:get:%s\' % user_document.getRelativeUrl(),\n
}\n
\n
response.setHeader(\'Content-Type\', mime_type)\n
return json.dumps(result_dict, indent=2)\n
</string>
</value>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
REQUEST=None
</string>
</value>
<value>
<string>
REQUEST=None
</string>
</value>
...
...
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Computer_getHateoasSoftwareInstallationList.py
0 → 100644
View file @
8db76f83
from
zExceptions
import
Unauthorized
from
AccessControl
import
getSecurityManager
if
REQUEST
is
None
:
raise
Unauthorized
response
=
REQUEST
.
RESPONSE
mime_type
=
'application/hal+json'
if
REQUEST
.
other
[
'method'
]
!=
"GET"
:
response
.
setStatus
(
405
)
return
""
elif
mime_type
!=
context
.
Base_handleAcceptHeader
([
mime_type
]):
response
.
setStatus
(
406
)
return
""
elif
context
.
getPortalType
()
!=
"Computer"
:
response
.
setStatus
(
403
)
return
""
import
json
result_dict
=
{
'_links'
:
{
"self"
:
{
"href"
:
context
.
Base_getRequestUrl
()
},
"index"
:
{
"href"
:
"urn:jio:get:%s"
%
context
.
getRelativeUrl
(),
"title"
:
"Computer"
},
"content"
:
[],
},
}
for
sql_obj
in
context
.
getPortalObject
().
portal_catalog
(
portal_type
=
'Software Installation'
,
default_aggregate_uid
=
context
.
getUid
(),
validation_state
=
'validated'
,
):
obj
=
sql_obj
.
getObject
()
result_dict
[
'_links'
][
'content'
].
append
({
'href'
:
'%s/ERP5Document_getHateoas'
%
obj
.
absolute_url
(),
'title'
:
obj
.
getUrlString
()
})
response
.
setHeader
(
'Content-Type'
,
mime_type
)
return
json
.
dumps
(
result_dict
,
indent
=
2
)
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Computer_getHateoasSoftwareInstallationList.xml
View file @
8db76f83
...
@@ -48,53 +48,6 @@
...
@@ -48,53 +48,6 @@
</object>
</object>
</value>
</value>
</item>
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
from zExceptions import Unauthorized\n
from AccessControl import getSecurityManager\n
if REQUEST is None:\n
raise Unauthorized\n
\n
response = REQUEST.RESPONSE\n
mime_type = \'application/hal+json\'\n
\n
if REQUEST.other[\'method\'] != "GET":\n
response.setStatus(405)\n
return ""\n
elif mime_type != context.Base_handleAcceptHeader([mime_type]):\n
response.setStatus(406)\n
return ""\n
elif context.getPortalType() != "Computer":\n
response.setStatus(403)\n
return ""\n
\n
import json\n
result_dict = {\n
\'_links\': {\n
"self": { "href": context.Base_getRequestUrl() },\n
"index": {\n
"href": "urn:jio:get:%s" % context.getRelativeUrl(),\n
"title": "Computer"\n
},\n
"content": [],\n
},\n
}\n
\n
for sql_obj in context.getPortalObject().portal_catalog(\n
portal_type=\'Software Installation\',\n
default_aggregate_uid=context.getUid(),\n
validation_state=\'validated\',\n
):\n
obj = sql_obj.getObject()\n
result_dict[\'_links\'][\'content\'].append({\n
\'href\': \'%s/ERP5Document_getHateoas\' % obj.absolute_url(),\n
\'title\': obj.getUrlString()\n
})\n
\n
response.setHeader(\'Content-Type\', mime_type)\n
return json.dumps(result_dict, indent=2)\n
</string>
</value>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
REQUEST=None
</string>
</value>
<value>
<string>
REQUEST=None
</string>
</value>
...
...
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/HostingSubscription_getHateoasInstanceList.py
0 → 100644
View file @
8db76f83
from
zExceptions
import
Unauthorized
from
AccessControl
import
getSecurityManager
if
REQUEST
is
None
:
raise
Unauthorized
response
=
REQUEST
.
RESPONSE
mime_type
=
'application/hal+json'
if
REQUEST
.
other
[
'method'
]
!=
"GET"
:
response
.
setStatus
(
405
)
return
""
elif
mime_type
!=
context
.
Base_handleAcceptHeader
([
mime_type
]):
response
.
setStatus
(
406
)
return
""
elif
context
.
getPortalType
()
!=
"Hosting Subscription"
:
response
.
setStatus
(
403
)
return
""
import
json
result_dict
=
{
'_links'
:
{
"self"
:
{
"href"
:
context
.
Base_getRequestUrl
()
},
"content"
:
[],
"index"
:
{
"href"
:
"urn:jio:get:%s"
%
context
.
getRelativeUrl
(),
"title"
:
"Hosting Subscription"
},
},
}
for
sql_obj
in
context
.
getPortalObject
().
portal_catalog
(
portal_type
=
[
'Software Instance'
,
'Slave Instance'
],
default_specialise_uid
=
context
.
getUid
(),
):
obj
=
sql_obj
.
getObject
()
result_dict
[
'_links'
][
'content'
].
append
({
'href'
:
'%s/ERP5Document_getHateoas'
%
obj
.
absolute_url
(),
'title'
:
obj
.
getTitle
()
})
response
.
setHeader
(
'Content-Type'
,
mime_type
)
return
json
.
dumps
(
result_dict
,
indent
=
2
)
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/HostingSubscription_getHateoasInstanceList.xml
View file @
8db76f83
...
@@ -48,52 +48,6 @@
...
@@ -48,52 +48,6 @@
</object>
</object>
</value>
</value>
</item>
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
from zExceptions import Unauthorized\n
from AccessControl import getSecurityManager\n
if REQUEST is None:\n
raise Unauthorized\n
\n
response = REQUEST.RESPONSE\n
mime_type = \'application/hal+json\'\n
\n
if REQUEST.other[\'method\'] != "GET":\n
response.setStatus(405)\n
return ""\n
elif mime_type != context.Base_handleAcceptHeader([mime_type]):\n
response.setStatus(406)\n
return ""\n
elif context.getPortalType() != "Hosting Subscription":\n
response.setStatus(403)\n
return ""\n
\n
import json\n
result_dict = {\n
\'_links\': {\n
"self": { "href": context.Base_getRequestUrl() },\n
"content": [],\n
"index": {\n
"href": "urn:jio:get:%s" % context.getRelativeUrl(),\n
"title": "Hosting Subscription"\n
},\n
},\n
}\n
\n
for sql_obj in context.getPortalObject().portal_catalog(\n
portal_type=[\'Software Instance\', \'Slave Instance\'],\n
default_specialise_uid=context.getUid(),\n
):\n
obj = sql_obj.getObject()\n
result_dict[\'_links\'][\'content\'].append({\n
\'href\': \'%s/ERP5Document_getHateoas\' % obj.absolute_url(),\n
\'title\': obj.getTitle()\n
})\n
\n
response.setHeader(\'Content-Type\', mime_type)\n
return json.dumps(result_dict, indent=2)\n
</string>
</value>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
REQUEST=None
</string>
</value>
<value>
<string>
REQUEST=None
</string>
</value>
...
...
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/HostingSubscription_getHateoasRootSoftwareInstance.py
0 → 100644
View file @
8db76f83
from
zExceptions
import
Unauthorized
from
AccessControl
import
getSecurityManager
if
REQUEST
is
None
:
raise
Unauthorized
response
=
REQUEST
.
RESPONSE
mime_type
=
'application/hal+json'
if
REQUEST
.
other
[
'method'
]
!=
"GET"
:
response
.
setStatus
(
405
)
return
""
elif
mime_type
!=
context
.
Base_handleAcceptHeader
([
mime_type
]):
response
.
setStatus
(
406
)
return
""
elif
context
.
getPortalType
()
!=
"Hosting Subscription"
:
response
.
setStatus
(
403
)
return
""
instance_list
=
context
.
getPredecessorValueList
()
for
instance
in
instance_list
:
if
instance
.
getTitle
()
==
context
.
getTitle
():
root_instance
=
instance
break
else
:
raise
Exception
(
'Root instance not found.'
)
import
json
result_dict
=
{
'_links'
:
{
"self"
:
{
"href"
:
context
.
Base_getRequestUrl
()
},
"content"
:
[
{
'href'
:
'%s/ERP5Document_getHateoas'
%
root_instance
.
getAbsoluteUrl
()},
],
"index"
:
{
"href"
:
"urn:jio:get:%s"
%
context
.
getRelativeUrl
(),
"title"
:
"Hosting Subscription"
},
},
}
response
.
setHeader
(
'Content-Type'
,
mime_type
)
return
json
.
dumps
(
result_dict
,
indent
=
2
)
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/HostingSubscription_getHateoasRootSoftwareInstance.xml
View file @
8db76f83
...
@@ -48,52 +48,6 @@
...
@@ -48,52 +48,6 @@
</object>
</object>
</value>
</value>
</item>
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
from zExceptions import Unauthorized\n
from AccessControl import getSecurityManager\n
if REQUEST is None:\n
raise Unauthorized\n
\n
response = REQUEST.RESPONSE\n
mime_type = \'application/hal+json\'\n
\n
if REQUEST.other[\'method\'] != "GET":\n
response.setStatus(405)\n
return ""\n
elif mime_type != context.Base_handleAcceptHeader([mime_type]):\n
response.setStatus(406)\n
return ""\n
elif context.getPortalType() != "Hosting Subscription":\n
response.setStatus(403)\n
return ""\n
\n
instance_list = context.getPredecessorValueList()\n
for instance in instance_list:\n
if instance.getTitle() == context.getTitle():\n
root_instance = instance\n
break\n
else:\n
raise Exception(\'Root instance not found.\')\n
\n
import json\n
result_dict = {\n
\'_links\': {\n
"self": { "href": context.Base_getRequestUrl() },\n
"content": [\n
{\'href\': \'%s/ERP5Document_getHateoas\' % root_instance.getAbsoluteUrl()},\n
],\n
"index": {\n
"href": "urn:jio:get:%s" % context.getRelativeUrl(),\n
"title": "Hosting Subscription"\n
},\n
},\n
}\n
\n
response.setHeader(\'Content-Type\', mime_type)\n
return json.dumps(result_dict, indent=2)\n
</string>
</value>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
REQUEST=None
</string>
</value>
<value>
<string>
REQUEST=None
</string>
</value>
...
...
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Instance_getHateoasInformation.py
0 → 100644
View file @
8db76f83
from
zExceptions
import
Unauthorized
from
AccessControl
import
getSecurityManager
if
REQUEST
is
None
:
raise
Unauthorized
response
=
REQUEST
.
RESPONSE
mime_type
=
'application/hal+json'
if
REQUEST
.
other
[
'method'
]
!=
"GET"
:
response
.
setStatus
(
405
)
return
""
elif
mime_type
!=
context
.
Base_handleAcceptHeader
([
mime_type
]):
response
.
setStatus
(
406
)
return
""
elif
context
.
getPortalType
()
not
in
[
"Software Instance"
,
"Slave Instance"
]:
response
.
setStatus
(
403
)
return
""
if
context
.
getSlapState
()
==
"stop_requested"
:
state
=
'stopped'
elif
context
.
getSlapState
()
==
"start_requested"
:
state
=
'started'
else
:
state
=
'destroyed'
import
json
result_dict
=
{
'title'
:
context
.
getTitle
(),
'slave'
:
context
.
getPortalType
()
==
'Slave Instance'
,
'software_type'
:
context
.
getSourceReference
(),
'parameter_dict'
:
context
.
getInstanceXmlAsDict
(),
'sla_dict'
:
context
.
getSlaXmlAsDict
(),
'connection_dict'
:
context
.
getConnectionXmlAsDict
(),
'requested_state'
:
state
,
'instance_guid'
:
context
.
getId
(),
'_links'
:
{
"self"
:
{
"href"
:
context
.
Base_getRequestUrl
()
},
"index"
:
{
"href"
:
"urn:jio:get:%s"
%
context
.
getRelativeUrl
(),
"title"
:
"Software Instance"
,
},
'software_release'
:
{
"href"
:
context
.
getUrlString
(),
}
},
}
response
.
setHeader
(
'Content-Type'
,
mime_type
)
return
json
.
dumps
(
result_dict
,
indent
=
2
)
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Instance_getHateoasInformation.xml
View file @
8db76f83
...
@@ -48,59 +48,6 @@
...
@@ -48,59 +48,6 @@
</object>
</object>
</value>
</value>
</item>
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
from zExceptions import Unauthorized\n
from AccessControl import getSecurityManager\n
if REQUEST is None:\n
raise Unauthorized\n
\n
response = REQUEST.RESPONSE\n
mime_type = \'application/hal+json\'\n
\n
if REQUEST.other[\'method\'] != "GET":\n
response.setStatus(405)\n
return ""\n
elif mime_type != context.Base_handleAcceptHeader([mime_type]):\n
response.setStatus(406)\n
return ""\n
elif context.getPortalType() not in ["Software Instance", "Slave Instance"]:\n
response.setStatus(403)\n
return ""\n
\n
if context.getSlapState() == "stop_requested":\n
state = \'stopped\'\n
elif context.getSlapState() == "start_requested":\n
state = \'started\'\n
else:\n
state = \'destroyed\'\n
\n
import json\n
result_dict = {\n
\'title\': context.getTitle(),\n
\'slave\': context.getPortalType() == \'Slave Instance\',\n
\'software_type\': context.getSourceReference(),\n
\'parameter_dict\': context.getInstanceXmlAsDict(),\n
\'sla_dict\': context.getSlaXmlAsDict(),\n
\'connection_dict\': context.getConnectionXmlAsDict(),\n
\'requested_state\': state,\n
\'instance_guid\': context.getId(),\n
\'_links\': {\n
"self": { "href": context.Base_getRequestUrl() },\n
"index": {\n
"href": "urn:jio:get:%s" % context.getRelativeUrl(),\n
"title": "Software Instance",\n
},\n
\'software_release\': {\n
"href": context.getUrlString(),\n
}\n
},\n
}\n
\n
response.setHeader(\'Content-Type\', mime_type)\n
return json.dumps(result_dict, indent=2)\n
</string>
</value>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
REQUEST=None
</string>
</value>
<value>
<string>
REQUEST=None
</string>
</value>
...
...
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Instance_getHateoasNews.py
0 → 100644
View file @
8db76f83
from
zExceptions
import
Unauthorized
from
AccessControl
import
getSecurityManager
if
REQUEST
is
None
:
raise
Unauthorized
response
=
REQUEST
.
RESPONSE
mime_type
=
'application/hal+json'
if
REQUEST
.
other
[
'method'
]
!=
"GET"
:
response
.
setStatus
(
405
)
return
""
elif
mime_type
!=
context
.
Base_handleAcceptHeader
([
mime_type
]):
response
.
setStatus
(
406
)
return
""
elif
context
.
getPortalType
()
not
in
[
"Software Instance"
,
"Slave Instance"
]:
response
.
setStatus
(
403
)
return
""
import
json
memcached_dict
=
context
.
getPortalObject
().
portal_memcached
.
getMemcachedDict
(
key_prefix
=
'slap_tool'
,
plugin_path
=
'portal_memcached/default_memcached_plugin'
)
try
:
d
=
memcached_dict
[
context
.
getReference
()]
except
KeyError
:
d
=
{
"user"
:
"SlapOS Master"
,
"text"
:
"#error no data found for %s"
%
context
.
getReference
()
}
else
:
d
=
json
.
loads
(
d
)
result_dict
=
{
'news'
:
[
d
],
'_links'
:
{
"self"
:
{
"href"
:
context
.
Base_getRequestUrl
()
},
# XXX current type
"index"
:
{
"href"
:
"urn:jio:get:%s"
%
context
.
getRelativeUrl
(),
"title"
:
"Software Instance"
},
},
}
response
.
setHeader
(
'Content-Type'
,
mime_type
)
return
json
.
dumps
(
result_dict
,
indent
=
2
)
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Instance_getHateoasNews.xml
View file @
8db76f83
...
@@ -48,57 +48,6 @@
...
@@ -48,57 +48,6 @@
</object>
</object>
</value>
</value>
</item>
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
from zExceptions import Unauthorized\n
from AccessControl import getSecurityManager\n
if REQUEST is None:\n
raise Unauthorized\n
\n
response = REQUEST.RESPONSE\n
mime_type = \'application/hal+json\'\n
\n
if REQUEST.other[\'method\'] != "GET":\n
response.setStatus(405)\n
return ""\n
elif mime_type != context.Base_handleAcceptHeader([mime_type]):\n
response.setStatus(406)\n
return ""\n
elif context.getPortalType() not in ["Software Instance", "Slave Instance"]:\n
response.setStatus(403)\n
return ""\n
\n
import json\n
\n
memcached_dict = context.getPortalObject().portal_memcached.getMemcachedDict(\n
key_prefix=\'slap_tool\',\n
plugin_path=\'portal_memcached/default_memcached_plugin\')\n
try:\n
d = memcached_dict[context.getReference()]\n
except KeyError:\n
d = {\n
"user": "SlapOS Master",\n
"text": "#error no data found for %s" % context.getReference()\n
}\n
else:\n
d = json.loads(d)\n
\n
result_dict = {\n
\'news\': [d],\n
\'_links\': {\n
"self": { "href": context.Base_getRequestUrl() },\n
# XXX current type\n
"index": {\n
"href": "urn:jio:get:%s" % context.getRelativeUrl(),\n
"title": "Software Instance"\n
},\n
},\n
}\n
\n
response.setHeader(\'Content-Type\', mime_type)\n
return json.dumps(result_dict, indent=2)\n
</string>
</value>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
REQUEST=None
</string>
</value>
<value>
<string>
REQUEST=None
</string>
</value>
...
...
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Instance_getHateoasRelatedHostingSubscription.py
0 → 100644
View file @
8db76f83
from
zExceptions
import
Unauthorized
from
AccessControl
import
getSecurityManager
if
REQUEST
is
None
:
raise
Unauthorized
response
=
REQUEST
.
RESPONSE
mime_type
=
'application/hal+json'
if
REQUEST
.
other
[
'method'
]
!=
"GET"
:
response
.
setStatus
(
405
)
return
""
elif
mime_type
!=
context
.
Base_handleAcceptHeader
([
mime_type
]):
response
.
setStatus
(
406
)
return
""
elif
context
.
getPortalType
()
not
in
[
"Software Instance"
,
"Slave Instance"
]:
response
.
setStatus
(
403
)
return
""
if
context
.
getSlapState
()
==
"stop_requested"
:
state
=
'stopped'
elif
context
.
getSlapState
()
==
"start_requested"
:
state
=
'started'
else
:
state
=
'destroyed'
import
json
result_dict
=
{
'_links'
:
{
"self"
:
{
"href"
:
context
.
Base_getRequestUrl
()
},
"index"
:
{
"href"
:
"urn:jio:get:%s"
%
context
.
getRelativeUrl
(),
"title"
:
"Software Instance"
,
},
'action_object_jump'
:
{
"href"
:
"%s/ERP5Document_getHateoas"
%
context
.
getSpecialiseValue
().
getAbsoluteUrl
(),
"title"
:
"Hosting Subscription"
,
}
},
}
response
.
setHeader
(
'Content-Type'
,
mime_type
)
return
json
.
dumps
(
result_dict
,
indent
=
2
)
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Instance_getHateoasRelatedHostingSubscription.xml
View file @
8db76f83
...
@@ -48,52 +48,6 @@
...
@@ -48,52 +48,6 @@
</object>
</object>
</value>
</value>
</item>
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
from zExceptions import Unauthorized\n
from AccessControl import getSecurityManager\n
if REQUEST is None:\n
raise Unauthorized\n
\n
response = REQUEST.RESPONSE\n
mime_type = \'application/hal+json\'\n
\n
if REQUEST.other[\'method\'] != "GET":\n
response.setStatus(405)\n
return ""\n
elif mime_type != context.Base_handleAcceptHeader([mime_type]):\n
response.setStatus(406)\n
return ""\n
elif context.getPortalType() not in ["Software Instance", "Slave Instance"]:\n
response.setStatus(403)\n
return ""\n
\n
if context.getSlapState() == "stop_requested":\n
state = \'stopped\'\n
elif context.getSlapState() == "start_requested":\n
state = \'started\'\n
else:\n
state = \'destroyed\'\n
\n
import json\n
result_dict = {\n
\'_links\': {\n
"self": { "href": context.Base_getRequestUrl() },\n
"index": {\n
"href": "urn:jio:get:%s" % context.getRelativeUrl(),\n
"title": "Software Instance",\n
},\n
\'action_object_jump\': {\n
"href": "%s/ERP5Document_getHateoas" % context.getSpecialiseValue().getAbsoluteUrl(),\n
"title": "Hosting Subscription",\n
}\n
},\n
}\n
\n
response.setHeader(\'Content-Type\', mime_type)\n
return json.dumps(result_dict, indent=2)\n
</string>
</value>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
REQUEST=None
</string>
</value>
<value>
<string>
REQUEST=None
</string>
</value>
...
...
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Person_getHateoasComputerList.py
0 → 100644
View file @
8db76f83
from
zExceptions
import
Unauthorized
from
AccessControl
import
getSecurityManager
if
REQUEST
is
None
:
raise
Unauthorized
response
=
REQUEST
.
RESPONSE
mime_type
=
'application/hal+json'
if
REQUEST
.
other
[
'method'
]
!=
"GET"
:
response
.
setStatus
(
405
)
return
""
elif
mime_type
!=
context
.
Base_handleAcceptHeader
([
mime_type
]):
response
.
setStatus
(
406
)
return
""
elif
context
.
getPortalType
()
!=
"Person"
:
response
.
setStatus
(
403
)
return
""
import
json
result_dict
=
{
'_links'
:
{
"self"
:
{
"href"
:
context
.
Base_getRequestUrl
()
},
# XXX current type
"index"
:
{
"href"
:
"urn:jio:get:%s"
%
context
.
getRelativeUrl
(),
"title"
:
"Person"
},
"content"
:
[],
},
}
for
sql_obj
in
context
.
getPortalObject
().
portal_catalog
(
portal_type
=
"Computer"
,
default_source_administration_uid
=
context
.
getUid
(),
):
obj
=
sql_obj
.
getObject
()
result_dict
[
'_links'
][
'content'
].
append
({
'href'
:
'%s/ERP5Document_getHateoas'
%
obj
.
absolute_url
(),
'title'
:
obj
.
getTitle
(),
})
response
.
setHeader
(
'Content-Type'
,
mime_type
)
return
json
.
dumps
(
result_dict
,
indent
=
2
)
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Person_getHateoasComputerList.xml
View file @
8db76f83
...
@@ -48,53 +48,6 @@
...
@@ -48,53 +48,6 @@
</object>
</object>
</value>
</value>
</item>
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
from zExceptions import Unauthorized\n
from AccessControl import getSecurityManager\n
if REQUEST is None:\n
raise Unauthorized\n
\n
response = REQUEST.RESPONSE\n
mime_type = \'application/hal+json\'\n
\n
if REQUEST.other[\'method\'] != "GET":\n
response.setStatus(405)\n
return ""\n
elif mime_type != context.Base_handleAcceptHeader([mime_type]):\n
response.setStatus(406)\n
return ""\n
elif context.getPortalType() != "Person":\n
response.setStatus(403)\n
return ""\n
\n
import json\n
result_dict = {\n
\'_links\': {\n
"self": { "href": context.Base_getRequestUrl() },\n
# XXX current type\n
"index": {\n
"href": "urn:jio:get:%s" % context.getRelativeUrl(),\n
"title": "Person"\n
},\n
"content": [],\n
},\n
}\n
\n
for sql_obj in context.getPortalObject().portal_catalog(\n
portal_type="Computer",\n
default_source_administration_uid=context.getUid(),\n
):\n
obj = sql_obj.getObject()\n
result_dict[\'_links\'][\'content\'].append({\n
\'href\': \'%s/ERP5Document_getHateoas\' % obj.absolute_url(),\n
\'title\': obj.getTitle(),\n
})\n
\n
response.setHeader(\'Content-Type\', mime_type)\n
return json.dumps(result_dict, indent=2)\n
</string>
</value>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
REQUEST=None
</string>
</value>
<value>
<string>
REQUEST=None
</string>
</value>
...
...
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Person_getHateoasHostingSubscriptionList.py
0 → 100644
View file @
8db76f83
from
zExceptions
import
Unauthorized
from
AccessControl
import
getSecurityManager
if
REQUEST
is
None
:
raise
Unauthorized
response
=
REQUEST
.
RESPONSE
mime_type
=
'application/hal+json'
if
REQUEST
.
other
[
'method'
]
!=
"GET"
:
response
.
setStatus
(
405
)
return
""
elif
mime_type
!=
context
.
Base_handleAcceptHeader
([
mime_type
]):
response
.
setStatus
(
406
)
return
""
elif
context
.
getPortalType
()
!=
"Person"
:
response
.
setStatus
(
403
)
return
""
import
json
result_dict
=
{
'_links'
:
{
"self"
:
{
"href"
:
context
.
Base_getRequestUrl
()
},
# XXX current type
"index"
:
{
"href"
:
"urn:jio:get:%s"
%
context
.
getRelativeUrl
(),
"title"
:
"Person"
},
"content"
:
[],
},
}
for
sql_obj
in
context
.
getPortalObject
().
portal_catalog
(
portal_type
=
"Hosting Subscription"
,
default_destination_section_uid
=
context
.
getUid
(),
validation_state
=
"validated"
):
obj
=
sql_obj
.
getObject
()
result_dict
[
'_links'
][
'content'
].
append
({
'href'
:
'%s/ERP5Document_getHateoas'
%
obj
.
absolute_url
(),
'title'
:
obj
.
getTitle
()
})
response
.
setHeader
(
'Content-Type'
,
mime_type
)
return
json
.
dumps
(
result_dict
,
indent
=
2
)
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Person_getHateoasHostingSubscriptionList.xml
View file @
8db76f83
...
@@ -48,54 +48,6 @@
...
@@ -48,54 +48,6 @@
</object>
</object>
</value>
</value>
</item>
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
from zExceptions import Unauthorized\n
from AccessControl import getSecurityManager\n
if REQUEST is None:\n
raise Unauthorized\n
\n
response = REQUEST.RESPONSE\n
mime_type = \'application/hal+json\'\n
\n
if REQUEST.other[\'method\'] != "GET":\n
response.setStatus(405)\n
return ""\n
elif mime_type != context.Base_handleAcceptHeader([mime_type]):\n
response.setStatus(406)\n
return ""\n
elif context.getPortalType() != "Person":\n
response.setStatus(403)\n
return ""\n
\n
import json\n
result_dict = {\n
\'_links\': {\n
"self": { "href": context.Base_getRequestUrl() },\n
# XXX current type\n
"index": {\n
"href": "urn:jio:get:%s" % context.getRelativeUrl(),\n
"title": "Person"\n
},\n
"content": [],\n
},\n
}\n
\n
for sql_obj in context.getPortalObject().portal_catalog(\n
portal_type="Hosting Subscription",\n
default_destination_section_uid=context.getUid(),\n
validation_state="validated"\n
):\n
obj = sql_obj.getObject()\n
result_dict[\'_links\'][\'content\'].append({\n
\'href\': \'%s/ERP5Document_getHateoas\' % obj.absolute_url(),\n
\'title\': obj.getTitle()\n
})\n
\n
response.setHeader(\'Content-Type\', mime_type)\n
return json.dumps(result_dict, indent=2)\n
</string>
</value>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
REQUEST=None
</string>
</value>
<value>
<string>
REQUEST=None
</string>
</value>
...
...
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Person_requestHateoasHostingSubscription.py
0 → 100644
View file @
8db76f83
from
zExceptions
import
Unauthorized
from
AccessControl
import
getSecurityManager
if
REQUEST
is
None
:
raise
Unauthorized
response
=
REQUEST
.
RESPONSE
mime_type
=
'application/json'
if
REQUEST
.
other
[
'method'
]
!=
"POST"
:
response
.
setStatus
(
405
)
return
""
elif
mime_type
!=
context
.
Base_getRequestHeader
(
'Content-Type'
):
response
.
setStatus
(
406
)
return
""
elif
context
.
getPortalType
()
!=
"Person"
:
response
.
setStatus
(
403
)
return
""
else
:
import
json
try
:
data_dict
=
json
.
loads
(
context
.
Base_getRequestBody
())
except
(
TypeError
,
ValueError
):
response
.
setStatus
(
400
)
return
""
else
:
def
dictToXml
(
dict_data
):
assert
same_type
(
dict_data
,
{})
result
=
"<?xml version='1.0' encoding='utf-8'?><instance>
\
n
"
for
key
,
value
in
dict_data
.
items
():
result
+=
""" <parameter id="%s">%s</parameter>
\
n
"""
%
(
key
.
encode
(
"UTF-8"
),
value
.
encode
(
"UTF-8"
))
result
+=
"</instance>"
return
result
try
:
parameter_kw
=
{
'software_release'
:
data_dict
[
'software_release'
].
encode
(
"UTF-8"
),
'software_title'
:
data_dict
[
'title'
].
encode
(
"UTF-8"
),
'software_type'
:
data_dict
[
'software_type'
].
encode
(
"UTF-8"
),
'instance_xml'
:
dictToXml
(
data_dict
[
'parameter'
]),
'sla_xml'
:
dictToXml
(
data_dict
[
'sla'
]),
'shared'
:
data_dict
[
'slave'
],
'state'
:
data_dict
[
'status'
].
encode
(
"UTF-8"
),
}
except
KeyError
:
response
.
setStatus
(
400
)
return
""
else
:
context
.
requestSoftwareInstance
(
**
parameter_kw
)
# XXX Return hosting subscription link
response
.
setStatus
(
201
)
return
""
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Person_requestHateoasHostingSubscription.xml
View file @
8db76f83
...
@@ -48,67 +48,6 @@
...
@@ -48,67 +48,6 @@
</object>
</object>
</value>
</value>
</item>
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string
encoding=
"cdata"
>
<![CDATA[
from zExceptions import Unauthorized\n
from AccessControl import getSecurityManager\n
if REQUEST is None:\n
raise Unauthorized\n
\n
response = REQUEST.RESPONSE\n
mime_type = \'application/json\'\n
\n
if REQUEST.other[\'method\'] != "POST":\n
response.setStatus(405)\n
return ""\n
elif mime_type != context.Base_getRequestHeader(\'Content-Type\'):\n
response.setStatus(406)\n
return ""\n
elif context.getPortalType() != "Person":\n
response.setStatus(403)\n
return ""\n
else:\n
import json\n
try:\n
data_dict = json.loads(context.Base_getRequestBody())\n
except (TypeError, ValueError):\n
response.setStatus(400)\n
return ""\n
else:\n
\n
def dictToXml(dict_data):\n
assert same_type(dict_data, {})\n
result = "<?xml version=\'1.0\' encoding=\'utf-8\'?>
<instance>
\\n"\n
for key, value in dict_data.items():\n
result += """
<parameter
id=
"%s"
>
%s
</parameter>
\\n""" % (key.encode("UTF-8"), value.encode("UTF-8"))\n
result += "
</instance>
"\n
return result\n
\n
try:\n
parameter_kw = {\n
\'software_release\': data_dict[\'software_release\'].encode("UTF-8"),\n
\'software_title\': data_dict[\'title\'].encode("UTF-8"),\n
\'software_type\': data_dict[\'software_type\'].encode("UTF-8"),\n
\'instance_xml\': dictToXml(data_dict[\'parameter\']),\n
\'sla_xml\': dictToXml(data_dict[\'sla\']),\n
\'shared\': data_dict[\'slave\'],\n
\'state\': data_dict[\'status\'].encode("UTF-8"),\n
}\n
except KeyError:\n
response.setStatus(400)\n
return ""\n
else:\n
\n
context.requestSoftwareInstance(**parameter_kw)\n
# XXX Return hosting subscription link\n
response.setStatus(201)\n
return ""\n
]]>
</string>
</value>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
REQUEST=None
</string>
</value>
<value>
<string>
REQUEST=None
</string>
</value>
...
...
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/SoftwareInstallation_getHateoasInformation.py
0 → 100644
View file @
8db76f83
from
zExceptions
import
Unauthorized
from
AccessControl
import
getSecurityManager
if
REQUEST
is
None
:
raise
Unauthorized
response
=
REQUEST
.
RESPONSE
mime_type
=
'application/hal+json'
if
REQUEST
.
other
[
'method'
]
!=
"GET"
:
response
.
setStatus
(
405
)
return
""
elif
mime_type
!=
context
.
Base_handleAcceptHeader
([
mime_type
]):
response
.
setStatus
(
406
)
return
""
elif
context
.
getPortalType
()
not
in
[
"Software Installation"
]:
response
.
setStatus
(
403
)
return
""
else
:
if
context
.
getSlapState
()
==
"stop_requested"
:
state
=
'stopped'
elif
context
.
getSlapState
()
==
"start_requested"
:
state
=
'started'
else
:
state
=
'destroyed'
import
json
result_dict
=
{
'title'
:
context
.
getTitle
(),
'status'
:
state
,
'_links'
:
{
"self"
:
{
"href"
:
context
.
Base_getRequestUrl
()
},
"index"
:
{
"href"
:
"urn:jio:get:%s"
%
context
.
getRelativeUrl
(),
"title"
:
"Software Installation"
},
},
}
url_string
=
context
.
getUrlString
(
None
)
if
url_string
is
not
None
:
result_dict
[
"_links"
][
"software_release"
]
=
{
"href"
:
url_string
}
response
.
setHeader
(
'Content-Type'
,
mime_type
)
return
json
.
dumps
(
result_dict
)
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/SoftwareInstallation_getHateoasInformation.xml
View file @
8db76f83
...
@@ -48,54 +48,6 @@
...
@@ -48,54 +48,6 @@
</object>
</object>
</value>
</value>
</item>
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
from zExceptions import Unauthorized\n
from AccessControl import getSecurityManager\n
if REQUEST is None:\n
raise Unauthorized\n
\n
response = REQUEST.RESPONSE\n
mime_type = \'application/hal+json\'\n
\n
if REQUEST.other[\'method\'] != "GET":\n
response.setStatus(405)\n
return ""\n
elif mime_type != context.Base_handleAcceptHeader([mime_type]):\n
response.setStatus(406)\n
return ""\n
elif context.getPortalType() not in ["Software Installation"]:\n
response.setStatus(403)\n
return ""\n
else:\n
\n
if context.getSlapState() == "stop_requested":\n
state = \'stopped\'\n
elif context.getSlapState() == "start_requested":\n
state = \'started\'\n
else:\n
state = \'destroyed\'\n
\n
import json\n
result_dict = {\n
\'title\': context.getTitle(),\n
\'status\': state,\n
\'_links\': {\n
"self": { "href": context.Base_getRequestUrl() },\n
"index": {\n
"href": "urn:jio:get:%s" % context.getRelativeUrl(),\n
"title": "Software Installation"\n
},\n
},\n
}\n
url_string = context.getUrlString(None)\n
if url_string is not None:\n
result_dict["_links"]["software_release"] = { "href": url_string }\n
\n
response.setHeader(\'Content-Type\', mime_type)\n
return json.dumps(result_dict)\n
</string>
</value>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
REQUEST=None
</string>
</value>
<value>
<string>
REQUEST=None
</string>
</value>
...
...
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/SoftwareInstallation_getHateoasNews.py
0 → 100644
View file @
8db76f83
from
zExceptions
import
Unauthorized
from
AccessControl
import
getSecurityManager
if
REQUEST
is
None
:
raise
Unauthorized
response
=
REQUEST
.
RESPONSE
mime_type
=
'application/hal+json'
if
REQUEST
.
other
[
'method'
]
!=
"GET"
:
response
.
setStatus
(
405
)
return
""
elif
mime_type
!=
context
.
Base_handleAcceptHeader
([
mime_type
]):
response
.
setStatus
(
406
)
return
""
elif
context
.
getPortalType
()
not
in
[
"Software Installation"
]:
raise
response
.
setStatus
(
403
)
return
""
import
json
memcached_dict
=
context
.
getPortalObject
().
portal_memcached
.
getMemcachedDict
(
key_prefix
=
'slap_tool'
,
plugin_path
=
'portal_memcached/default_memcached_plugin'
)
try
:
d
=
memcached_dict
[
context
.
getReference
()]
except
KeyError
:
d
=
{
"user"
:
"SlapOS Master"
,
"text"
:
"#error no data found for %s"
%
context
.
getReference
()
}
else
:
d
=
json
.
loads
(
d
)
result_dict
=
{
'news'
:
[
d
],
'_links'
:
{
"self"
:
{
"href"
:
context
.
Base_getRequestUrl
()
},
# XXX current type
"index"
:
{
"href"
:
"urn:jio:get:%s"
%
context
.
getRelativeUrl
(),
"title"
:
"Software Instance"
},
},
}
response
.
setHeader
(
'Content-Type'
,
mime_type
)
return
json
.
dumps
(
result_dict
,
indent
=
2
)
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/SoftwareInstallation_getHateoasNews.xml
View file @
8db76f83
...
@@ -48,58 +48,6 @@
...
@@ -48,58 +48,6 @@
</object>
</object>
</value>
</value>
</item>
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
from zExceptions import Unauthorized\n
from AccessControl import getSecurityManager\n
if REQUEST is None:\n
raise Unauthorized\n
\n
response = REQUEST.RESPONSE\n
mime_type = \'application/hal+json\'\n
\n
if REQUEST.other[\'method\'] != "GET":\n
response.setStatus(405)\n
return ""\n
elif mime_type != context.Base_handleAcceptHeader([mime_type]):\n
response.setStatus(406)\n
return ""\n
elif context.getPortalType() not in ["Software Installation"]:\n
raise\n
response.setStatus(403)\n
return ""\n
\n
import json\n
\n
memcached_dict = context.getPortalObject().portal_memcached.getMemcachedDict(\n
key_prefix=\'slap_tool\',\n
plugin_path=\'portal_memcached/default_memcached_plugin\')\n
try:\n
d = memcached_dict[context.getReference()]\n
except KeyError:\n
d = {\n
"user": "SlapOS Master",\n
"text": "#error no data found for %s" % context.getReference()\n
}\n
else:\n
d = json.loads(d)\n
\n
result_dict = {\n
\'news\': [d],\n
\'_links\': {\n
"self": { "href": context.Base_getRequestUrl() },\n
# XXX current type\n
"index": {\n
"href": "urn:jio:get:%s" % context.getRelativeUrl(),\n
"title": "Software Instance"\n
},\n
},\n
}\n
\n
response.setHeader(\'Content-Type\', mime_type)\n
return json.dumps(result_dict, indent=2)\n
</string>
</value>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
REQUEST=None
</string>
</value>
<value>
<string>
REQUEST=None
</string>
</value>
...
...
master/bt5/slapos_hypermedia/bt/dependency_list
View file @
8db76f83
erp5_hal_json_style
erp5_hal_json_style
slapos_cloud
slapos_cloud
slapos_slap_tool
slapos_slap_tool
\ No newline at end of file
Write
Preview
Markdown
is supported
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