Commit 81271124 authored by Jérome Perrin's avatar Jérome Perrin Committed by Arnaud Fontaine

core: py3

parent aba0ca3f
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
Generate a HTML Summary of an object. Generate a HTML Summary of an object.
Use "No ZODB" approach if possible. Use "No ZODB" approach if possible.
""" """
import six
request = context.REQUEST request = context.REQUEST
portal = context.getPortalObject() portal = context.getPortalObject()
is_temp_object = context.isTempObject() is_temp_object = context.isTempObject()
...@@ -40,7 +41,7 @@ else: ...@@ -40,7 +41,7 @@ else:
modification_date = context.modification_date modification_date = context.modification_date
document_web_section_list = web_site.getWebSectionValueList(context) document_web_section_list = web_site.getWebSectionValueList(context)
inline_popup = context.Document_getPopupInfo(web_site, document_web_section_list) inline_popup = context.Document_getPopupInfo(web_site, document_web_section_list)
if isinstance(inline_popup, unicode): if six.PY2 and not isinstance(inline_popup, str):
inline_popup = inline_popup.encode('utf-8') inline_popup = inline_popup.encode('utf-8')
found = context.Base_showFoundText() found = context.Base_showFoundText()
portal_type = context.getTranslatedPortalType() portal_type = context.getTranslatedPortalType()
......
...@@ -37,7 +37,7 @@ from hashlib import md5 ...@@ -37,7 +37,7 @@ from hashlib import md5
skipped_workflow_id_list = ['delivery_causality_workflow',] skipped_workflow_id_list = ['delivery_causality_workflow',]
def generateUid(portal_type, workflow_id, workflow_state): def generateUid(portal_type, workflow_id, workflow_state):
return 'new_' + md5('%s/%s/%s' % (portal_type, workflow_id, workflow_state)).hexdigest() return 'new_' + md5(('%s/%s/%s' % (portal_type, workflow_id, workflow_state)).encode()).hexdigest()
def getDocumentGroupByWorkflowStateList(self, form_id='', **kw): def getDocumentGroupByWorkflowStateList(self, form_id='', **kw):
"""This returns the list of all "document groups", ie document of the same """This returns the list of all "document groups", ie document of the same
......
...@@ -24,7 +24,7 @@ else: ...@@ -24,7 +24,7 @@ else:
request = container.REQUEST request = container.REQUEST
request_form = request.form request_form = request.form
for k in request_form.keys(): for k in list(request_form):
del request_form[k] del request_form[k]
request.form.update(old_request) request.form.update(old_request)
......
...@@ -18,9 +18,13 @@ if is_gadget_mode: ...@@ -18,9 +18,13 @@ if is_gadget_mode:
def getRandomDocumentTextExcerpt(document_text): def getRandomDocumentTextExcerpt(document_text):
# try to get somewhat arbitrary choice of searchable attrs # try to get somewhat arbitrary choice of searchable attrs
if isinstance(document_text, str) and document_text!='': if isinstance(document_text, str) and document_text!='':
if six.PY2:
document_text = document_text.decode(encoding, 'ignore') document_text = document_text.decode(encoding, 'ignore')
start = min(len(document_text) - 300, 200) start = min(len(document_text) - 300, 200)
return '... %s ...' %document_text[start:start + max_text_length].encode(encoding) result = '... %s ...' %document_text[start:start + max_text_length]
if six.PY2:
result = result.encode(encoding)
return result
else: else:
return '' return ''
...@@ -54,6 +58,7 @@ else: ...@@ -54,6 +58,7 @@ else:
result = ' '.join(map(str, found_text_fragments)) result = ' '.join(map(str, found_text_fragments))
# Document may contains charactors which utf8 codec cannot decode. # Document may contains charactors which utf8 codec cannot decode.
if six.PY2:
unicode_result = result.decode(encoding, 'ignore') unicode_result = result.decode(encoding, 'ignore')
result = unicode_result.encode(encoding) result = unicode_result.encode(encoding)
......
...@@ -21,10 +21,10 @@ else: ...@@ -21,10 +21,10 @@ else:
else: else:
filtered_uid_dict[uid] = 1 filtered_uid_dict[uid] = 1
if len(filtered_uid_dict.keys()) > 0 : if len(filtered_uid_dict) > 0 :
selection_tool.checkAll(selection_name, uids, REQUEST=None) selection_tool.checkAll(selection_name, uids, REQUEST=None)
selection_tool.setSelectionToIds(selection_name, selection_tool.setSelectionToIds(selection_name,
filtered_uid_dict.keys(), REQUEST=request) list(filtered_uid_dict), REQUEST=request)
url = selection_tool.getSelectionListUrlFor( url = selection_tool.getSelectionListUrlFor(
selection_name, REQUEST=request) selection_name, REQUEST=request)
......
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