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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos.core
Commits
5e3efc5c
Commit
5e3efc5c
authored
Feb 07, 2014
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Embed the form definition.
parent
19965ffb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
35 deletions
+86
-35
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.xml
...tal_skins/erp5_hal_json_style/ERP5Document_getHateoas.xml
+85
-34
master/bt5/slapos_jio/bt/revision
master/bt5/slapos_jio/bt/revision
+1
-1
No files found.
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.xml
View file @
5e3efc5c
...
@@ -153,39 +153,24 @@ def renderForm(form, response_dict):\n
...
@@ -153,39 +153,24 @@ def renderForm(form, response_dict):\n
"title": context.getTitle()\n
"title": context.getTitle()\n
}\n
}\n
\n
\n
# # XXX form action update, etc\n
form_definition = {\n
# def renderRawField(field):\n
"_links": {\n
# meta_type = field.meta_type\n
"self": {\n
# if meta_type == "MethodField":\n
"href": "%s/%s?mode=form_definition&skin_id=%s" % \\\n
# result = {\n
(site_root.absolute_url(), script.id, form.id),\n
# "meta_type": field.meta_type\n
\'name\': form.id\n
# }\n
}\n
# else:\n
}\n
# result = {\n
}\n
# "meta_type": field.meta_type,\n
renderFormDefinition(form, form_definition)\n
# "_values": field.values,\n
response_dict[\'_embedded\'] = {\n
# # XXX TALES expression is not JSON serializable by default\n
\'form_definition\': form_definition\n
# # "_tales": field.tales\n
}\n
# "_overrides": field.overrides\n
response_dict[\'_links\'][\'form_definition\'] = {\n
# }\n
"href": "%s/%s?mode=form_definition&skin_id=%s" % \\\n
# if meta_type == "ProxyField":\n
(site_root.absolute_url(), script.id, form.id),\n
# result[\'_delegated_list\'] = field.delegated_list\n
\'name\': form.id\n
# # try:\n
}\n
# # result[\'_delegated_list\'].pop(\'list_method\')\n
# # except KeyError:\n
# # pass\n
# \n
# # XXX ListMethod is not JSON serialized by default\n
# try:\n
# result[\'_values\'].pop(\'list_method\')\n
# except KeyError:\n
# pass\n
# try:\n
# result[\'_overrides\'].pop(\'list_method\')\n
# except KeyError:\n
# pass\n
# return result\n
# \n
\n
\n
group_list = []\n
group_list = []\n
for group in form.Form_getGroupTitleAndId():\n
for group in form.Form_getGroupTitleAndId():\n
...
@@ -225,6 +210,60 @@ def renderForm(form, response_dict):\n
...
@@ -225,6 +210,60 @@ def renderForm(form, response_dict):\n
# }\n
# }\n
\n
\n
\n
\n
# XXX form action update, etc\n
def renderRawField(field):\n
meta_type = field.meta_type\n
\n
return {\n
"meta_type": field.meta_type\n
}\n
\n
\n
if meta_type == "MethodField":\n
result = {\n
"meta_type": field.meta_type\n
}\n
else:\n
result = {\n
"meta_type": field.meta_type,\n
"_values": field.values,\n
# XXX TALES expression is not JSON serializable by default\n
# "_tales": field.tales\n
"_overrides": field.overrides\n
}\n
if meta_type == "ProxyField":\n
result[\'_delegated_list\'] = field.delegated_list\n
# try:\n
# result[\'_delegated_list\'].pop(\'list_method\')\n
# except KeyError:\n
# pass\n
\n
# XXX ListMethod is not JSON serialized by default\n
try:\n
result[\'_values\'].pop(\'list_method\')\n
except KeyError:\n
pass\n
try:\n
result[\'_overrides\'].pop(\'list_method\')\n
except KeyError:\n
pass\n
return result\n
\n
\n
def renderFormDefinition(form, response_dict):\n
group_list = []\n
for group in form.Form_getGroupTitleAndId():\n
\n
if group[\'gid\'].find(\'hidden\') < 0:\n
field_list = []\n
\n
for field in form.get_fields_in_group(group[\'goid\']):\n
field_list.append((field.id, renderRawField(field)))\n
\n
group_list.append((group[\'gid\'], field_list))\n
response_dict["group_list"] = group_list\n
\n
\n
context.Base_prepareCorsResponse(RESPONSE=response)\n
context.Base_prepareCorsResponse(RESPONSE=response)\n
\n
\n
mime_type = \'application/hal+json\'\n
mime_type = \'application/hal+json\'\n
...
@@ -358,6 +397,7 @@ elif mode == \'document\':\n
...
@@ -358,6 +397,7 @@ elif mode == \'document\':\n
\'_view\': embedded_dict\n
\'_view\': embedded_dict\n
# embedded_action_key: embedded_dict\n
# embedded_action_key: embedded_dict\n
}\n
}\n
# result_dict[\'_links\']["_view"] = {"href": embedded_url}\n
\n
\n
# Include properties in document JSON\n
# Include properties in document JSON\n
# XXX Extract from renderer form?\n
# XXX Extract from renderer form?\n
...
@@ -729,6 +769,17 @@ elif mode == \'form\':\n
...
@@ -729,6 +769,17 @@ elif mode == \'form\':\n
renderForm(form, result_dict)\n
renderForm(form, result_dict)\n
\n
\n
\n
\n
elif mode == \'form_definition\':\n
#################################################\n
# Get raw form definitions\n
#################################################\n
if REQUEST.other[\'method\'] != "GET":\n
response.setStatus(405)\n
return ""\n
\n
form = getattr(portal, skin_id)\n
renderFormDefinition(form, result_dict)\n
\n
else:\n
else:\n
raise NotImplementedError, "Unsupported mode %s" % mode\n
raise NotImplementedError, "Unsupported mode %s" % mode\n
\n
\n
...
@@ -740,7 +791,7 @@ return json.dumps(result_dict, indent=2)\n
...
@@ -740,7 +791,7 @@ return json.dumps(result_dict, indent=2)\n
</item>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
REQUEST=None, response=None, view=None, mode=\'document\', query=None, select_list=None, limit=None, form=None
</string>
</value>
<value>
<string>
REQUEST=None, response=None, view=None, mode=\'document\', query=None, select_list=None, limit=None, form=None
, skin_id=None
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
...
...
master/bt5/slapos_jio/bt/revision
View file @
5e3efc5c
2
3
\ No newline at end of file
\ 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