Commit 19965ffb authored by Romain Courteaud's avatar Romain Courteaud

Add webservice links custom to slapos.org website.

This is just a proof of concept without genericity.
parent 72b31104
def Listbox_getListMethodName(self, field):
""" XXXX"""
list_method = field.get_value('list_method')
try:
list_method_name = getattr(list_method, 'method_name')
except AttributeError:
list_method_name = list_method
return list_method_name
......@@ -67,7 +67,7 @@ request_form = context.ERP5Site_filterParameterList(request_form)\n
request_form.update(keep_items)\n
\n
if form_id == \'view\':\n
redirect_url = context.absolute_url()\n
redirect_url = "%s/ERP5Document_getHateoas" % context.absolute_url()\n
else:\n
redirect_url = \'%s/%s\' % (context.absolute_url(), form_id)\n
\n
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if REQUEST.other[\'method\'] != "POST":\n
response.setStatus(405)\n
return ""\n
\n
computer = context\n
computer.requestSoftwareRelease(software_release_url=software_release, state=\'available\')\n
\n
return context.REQUEST.get(\'software_installation_url\').Base_redirect()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>software_release, REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Computer_requestInstallationFromJio</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if REQUEST.other[\'method\'] != "POST":\n
response.setStatus(405)\n
return ""\n
\n
import json\n
\n
computer = context\n
request = context.REQUEST\n
response = REQUEST.RESPONSE\n
\n
context.Base_prepareCorsResponse(RESPONSE=response)\n
\n
computer.generateCertificate()\n
\n
return json.dumps({\n
\'certificate\': request.get(\'computer_certificate\'),\n
\'key\': request.get(\'computer_key\')\n
}, indent=2)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Computer_requestNewComputerCertificateFromJio</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if REQUEST.other[\'method\'] != "POST":\n
response.setStatus(405)\n
return ""\n
\n
computer = context\n
response = REQUEST.RESPONSE\n
context.Base_prepareCorsResponse(RESPONSE=response)\n
\n
computer.revokeCertificate()\n
\n
return ""\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Computer_revokeComputerCertificateFromJio</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if REQUEST.other[\'method\'] != "POST":\n
response.setStatus(405)\n
return ""\n
\n
portal = context.getPortalObject()\n
computer = context\n
\n
if allocation_scope == \'open/public\':\n
# Public computer capacity is handle by an alarm\n
capacity_scope = \'close\'\n
elif allocation_scope.startswith(\'open\'):\n
# Capacity is not handled for \'private\' computers\n
capacity_scope = \'open\'\n
else:\n
capacity_scope = \'close\'\n
\n
edit_kw = {\n
\'allocation_scope\': allocation_scope,\n
\'capacity_scope\': capacity_scope,\n
}\n
\n
self_person = computer.getSourceAdministrationValue(portal_type="Person")\n
self_email = self_person.getDefaultEmailCoordinateText()\n
if allocation_scope == \'open/public\':\n
# reset friends and update in place\n
edit_kw[\'subject_list\'] = [\'\']\n
edit_kw[\'destination_section\'] = None\n
elif allocation_scope == \'open/personal\':\n
# reset friends to self and update in place\n
edit_kw[\'subject_list\'] = [self_email]\n
edit_kw[\'destination_section_value\'] = self_person\n
else:\n
if self_email not in subject_list:\n
# add self as friend\n
subject_list.append(self_email)\n
edit_kw[\'subject_list\'] = subject_list\n
\n
computer.edit(**edit_kw)\n
\n
return ""\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>allocation_scope, subject_list, REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Computer_updateAllocationScopeFromJio</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if REQUEST.other[\'method\'] != "POST":\n
response.setStatus(405)\n
return ""\n
\n
if action not in ("started", "stopped", "destroyed"):\n
raise NotImplementedError, "Unknown action %s" % action\n
\n
person = context.getDestinationSectionValue()\n
person.requestSoftwareInstance(\n
state=action,\n
software_release=context.getUrlString(),\n
software_title=context.getTitle(),\n
software_type=context.getSourceReference(),\n
instance_xml=context.getTextContent(),\n
sla_xml=context.getSlaXml(),\n
shared=context.isRootSlave()\n
)\n
\n
context.Base_redirect()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>action, REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>HostingSubscription_changeRequestedStateFromJio</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if REQUEST.other[\'method\'] != "POST":\n
response.setStatus(405)\n
return ""\n
\n
person = context\n
\n
person.requestComputer(computer_title=computer_title)\n
return context.getPortalObject().restrictedTraverse(context.REQUEST.get(\'computer\')).Base_redirect()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>computer_title, REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Person_requestComputerFromJio</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if REQUEST.other[\'method\'] != "POST":\n
response.setStatus(405)\n
return ""\n
\n
portal = context.getPortalObject()\n
\n
network_portal_type = "Computer Network"\n
\n
reference = "NET-%s" % portal.portal_ids.generateNewId(\n
id_group=\'slap_network_reference\',\n
id_generator=\'uid\')\n
\n
module = portal.getDefaultModule(portal_type=network_portal_type)\n
network = module.newContent(\n
portal_type=network_portal_type,\n
title=network_title,\n
reference=reference,\n
source_administration=context.getRelativeUrl()\n
)\n
network.validate()\n
\n
return network.Base_redirect()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>network_title, REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Person_requestComputerNetworkFromJio</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if REQUEST.other[\'method\'] != "POST":\n
response.setStatus(405)\n
return ""\n
\n
person = context\n
person.requestSoftwareInstance(\n
state=state,\n
software_release=software_release,\n
software_title=software_title,\n
software_type=software_type,\n
instance_xml=instance_xml,\n
sla_xml=sla_xml,\n
shared=int(shared)\n
)\n
\n
return context.REQUEST.get(\'request_hosting_subscription\').Base_redirect()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state, software_release, software_title, software_type, instance_xml, sla_xml, shared, REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Person_requestInstanceFromJio</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if REQUEST.other[\'method\'] != "POST":\n
response.setStatus(405)\n
return ""\n
\n
person = context\n
portal = person.getPortalObject()\n
\n
support_request_template = portal.restrictedTraverse(\n
portal.portal_preferences.getPreferredSupportRequestTemplate())\n
support_request = support_request_template.Base_createCloneDocument(batch_mode=1)\n
\n
support_request.edit(\n
title=title,\n
destination_decision_value=person,\n
resource=resource,\n
start_date=DateTime(),\n
)\n
support_request.validate(comment="Submitted from the web site contact form")\n
\n
web_message_template = portal.restrictedTraverse(\n
portal.portal_preferences.getPreferredWebMessageTemplate())\n
web_message = web_message_template.Base_createCloneDocument(batch_mode=1)\n
# XXX init script is not called when cloning?\n
web_message.Event_init()\n
web_message.edit(\n
title=title,\n
content_type="text/plain",\n
text_content=description,\n
source_value=person,\n
resource=resource,\n
start_date=DateTime(),\n
follow_up_value=support_request,\n
)\n
web_message.stop(comment="Submitted from the web site contact form")\n
\n
return support_request.Base_redirect()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>title, resource, description, REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Person_requestTicketFromJio</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if REQUEST.other[\'method\'] != "POST":\n
response.setStatus(405)\n
return ""\n
\n
context.getAggregateValue(portal_type=\'Computer\').requestSoftwareRelease(software_release_url=context.getUrlString(), state=\'destroyed\')\n
\n
return ""\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareInstallation_destroyFromJio</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if REQUEST.other[\'method\'] != "POST":\n
response.setStatus(405)\n
return ""\n
\n
ticket = context\n
portal = ticket.getPortalObject()\n
person = ticket.getDestinationDecisionValue()\n
\n
web_message_template = portal.restrictedTraverse(\n
portal.portal_preferences.getPreferredWebMessageTemplate())\n
web_message = web_message_template.Base_createCloneDocument(batch_mode=1)\n
# XXX init script is not called when cloning?\n
web_message.Event_init()\n
web_message.edit(\n
title="Re: %s" % context.getTitle(),\n
content_type="text/plain",\n
text_content=description,\n
source_value=person,\n
resource=ticket.getResource(),\n
start_date=DateTime(),\n
follow_up_value=ticket,\n
)\n
web_message.stop(comment="Submitted from the web site contact form")\n
if portal.portal_workflow.isTransitionPossible(context, "validate"):\n
context.validate(comment="See %s" % web_message.getRelativeUrl())\n
\n
return ""\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>description, REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Ticket_updateFromJio</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
1
\ No newline at end of file
2
\ No newline at end of file
HalStyle
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment