Commit b9c6675d authored by Jérome Perrin's avatar Jérome Perrin

core: py3

parent 16073c3a
......@@ -2,6 +2,7 @@
Generate a HTML Summary of an object.
Use "No ZODB" approach if possible.
"""
import six
request = context.REQUEST
portal = context.getPortalObject()
is_temp_object = context.isTempObject()
......@@ -40,7 +41,7 @@ else:
modification_date = context.modification_date
document_web_section_list = web_site.getWebSectionValueList(context)
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')
found = context.Base_showFoundText()
portal_type = context.getTranslatedPortalType()
......
......@@ -37,7 +37,7 @@ from hashlib import md5
skipped_workflow_id_list = ['delivery_causality_workflow',]
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):
"""This returns the list of all "document groups", ie document of the same
......
......@@ -24,7 +24,7 @@ else:
request = container.REQUEST
request_form = request.form
for k in request_form.keys():
for k in list(request_form):
del request_form[k]
request.form.update(old_request)
......
......@@ -4,5 +4,5 @@ td = context.newContent(
portal_type='OOo Document',
temp_object=True,
base_content_type=base_content_type,
base_data='not empty')
base_data=b'not empty')
return [('', '')] + td.getTargetFormatItemList()
......@@ -18,9 +18,13 @@ if is_gadget_mode:
def getRandomDocumentTextExcerpt(document_text):
# try to get somewhat arbitrary choice of searchable attrs
if isinstance(document_text, str) and document_text!='':
document_text = document_text.decode(encoding, 'ignore')
if six.PY2:
document_text = document_text.decode(encoding, 'ignore')
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:
return ''
......@@ -54,7 +58,8 @@ else:
result = ' '.join(map(str, found_text_fragments))
# Document may contains charactors which utf8 codec cannot decode.
unicode_result = result.decode(encoding, 'ignore')
result = unicode_result.encode(encoding)
if six.PY2:
unicode_result = result.decode(encoding, 'ignore')
result = unicode_result.encode(encoding)
return result
......@@ -21,10 +21,10 @@ else:
else:
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.setSelectionToIds(selection_name,
filtered_uid_dict.keys(), REQUEST=request)
list(filtered_uid_dict), REQUEST=request)
url = selection_tool.getSelectionListUrlFor(
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