Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Eteri
erp5
Commits
e4a1dc91
Commit
e4a1dc91
authored
Oct 02, 2017
by
Tomáš Peterka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[json_style] Add yet-another attribut resolution method to mode=search results
parent
fa05d604
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
+16
-2
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
...rtal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
+16
-2
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
View file @
e4a1dc91
...
...
@@ -8,6 +8,7 @@ import time
from
email.Utils
import
formatdate
import
re
from
zExceptions
import
Unauthorized
from
Products.ERP5Type.Utils
import
UpperCase
if
REQUEST
is
None
:
REQUEST
=
context
.
REQUEST
...
...
@@ -1244,14 +1245,27 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
else
:
contents_value
=
search_property_getter
(
search_result
,
select
)
if
contents_value
is
None
:
accessor_name
=
'get'
+
UpperCase
(
select
)
# check for attribute getter in the whole chain of acquisition
# why? because it does not work otherways (it's most probably wrong)
try
:
# this was copied out from ListsBoxHTMLRenderer
if
hasattr
(
search_result
,
accessor_name
):
contents_value
=
getattr
(
search_result
,
accessor_name
)()
except
(
AttributeError
,
KeyError
,
Unauthorized
):
context
.
log
(
"Could not evaluate {} nor {} on {}"
.
format
(
select
,
accessor_name
,
search_result
))
context
.
log
(
"search_property_getter({!s}, {}) -> {!s}"
.
format
(
search_result
,
select
,
contents_value
))
if
contents_value
is
not
None
:
if
same_type
(
contents_value
,
DateTime
()):
# Serialize DateTime
contents_value
=
contents_value
.
rfc822
()
elif
isinstance
(
contents_value
,
datetime
.
date
):
contents_value
=
formatdate
(
time
.
mktime
(
contents_value
.
timetuple
()))
elif
getattr
(
contents_value
,
'translate'
,
None
)
is
not
None
:
elif
hasattr
(
contents_value
,
'translate'
)
:
contents_value
=
"%s"
%
contents_value
contents_item
[
select
]
=
contents_value
...
...
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