Commit cb9232a2 authored by Jérome Perrin's avatar Jérome Perrin Committed by Eteri

web: fix problems reported by pylint

parent e79ffe89
......@@ -12,6 +12,8 @@ Export the web page and its components to a single (m)html file.
TODO: export same components into one mhtml attachment if possible.
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
from zExceptions import Unauthorized
from base64 import b64encode, b64decode
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>group_by_criterion=[\'left\', \'right\', \'center\', \'bottom\', \'hidden\']</string> </value>
<value> <string>group_by_criterion=(\'left\', \'right\', \'center\', \'bottom\', \'hidden\')</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -20,11 +20,6 @@
"""
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, ComplexQuery
if portal is None: portal = context.getPortalObject()
portal_catalog = portal.portal_catalog
# The list of portal types here should be large enough to include
# all portal_types defined in the various sections so that
# href tags which point to a document by reference can still work.
valid_portal_type_list = portal.getPortalDocumentTypeList()
# Find the applicable language
if language is None:
......
......@@ -3,7 +3,8 @@ Export the web page and its components to a single (m)html file.
see Base_convertHtmlToSingleFile for documentation
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
data = context.Base_convertHtmlToSingleFile(
context.getTextContent(""),
allow_script=allow_script,
......
......@@ -5,6 +5,8 @@
"""
# Initialise result
sub_field_list = []
if default_sub_field_property_dict is None:
default_sub_field_property_dict = {}
# Maximum size of the MultiListField
default_sub_field_property_dict.update({
......@@ -17,7 +19,7 @@ default_sub_field_property_dict.update({
})
z = 0
for i in range(1):
for _ in range(1):
new_dict = default_sub_field_property_dict.copy()
new_dict['title'] = '&nbsp;'
new_dict['key'] = str(z)
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>item_list, value_list, default_sub_field_property_dict={}, is_right_display=0</string> </value>
<value> <string>item_list, value_list, default_sub_field_property_dict=None, is_right_display=0</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
request = context.REQUEST
request_form = context.REQUEST.form
request_form = request.form
from ZTUtils import make_query
portal = context.getPortalObject()
title = context.getTitle('Unknown')
......
......@@ -5,6 +5,9 @@
category -- the category to use
"""
# our pylint integration does not support global variabled in zope python script.
# pylint: disable=global-variable-undefined
from ZODB.POSException import ConflictError
portal = context.getPortalObject()
translateString = context.Base_translateString
......@@ -20,7 +23,7 @@ def getNiceID(s):
s = s.lower()
s = s.split()
s = '-'.join(s)
s = filter(lambda c: c in valid_char, s)
s = [c for c in s if c in valid_char]
s = s.replace('_', '-')
return s
......@@ -77,7 +80,7 @@ def createWebSectionFromCategoryValue(container, category, depth, section_id=Non
new_section.updateLocalRolesOnSecurityGroups()
except ConflictError:
raise
except:
except Exception:
failed_list.append(category.getRelativeUrl())
else:
new_section = container[section_id]
......
......@@ -24,11 +24,6 @@
portal skins. It is recommended to use the first approach
to host multiple sites on a single ERP5Site instance.
"""
portal_object = context.getPortalObject()
# First find the Web Section or Web Site we belong to
current_section = context.getWebSectionValue()
# First get all the applicable references
# There might be more than one reference due to security differences
# (ex. a default restricted web page and a default public web page)
......
request = context.REQUEST
portal = context.getPortalObject()
title = context.getTitle('Unknown')
translateString = context.Base_translateString
......
......@@ -10,11 +10,11 @@
- you need to adjust group, function and site to your needs
"""
# pylint: disable=unreachable
# since the following code is just an example, we simply raise an exception so that
# it is not executed actually.
raise NotImplementedError
from Products.Formulator.Errors import ValidationError, FormValidationError
portal = context.getPortalObject()
translateString = context.Base_translateString
website = context.getWebSiteValue()
......@@ -25,7 +25,7 @@ result, result_type = context.Base_edit(form_id, silent_mode=1, field_prefix='yo
# Return if not appropriate
if result_type != 'edit':
return result
kw, encapsulated_editor_list = result
kw, _ = result
# Set default values
person_group = kw.get('group', None)
......@@ -55,11 +55,11 @@ person.validate()
#person.immediateReindexObject()
# Create default career
career = person.newContent(portal_type='Career',
id='default_career',
group=person_group,
function=person_function,
role=person_role)
person.newContent(portal_type='Career',
id='default_career',
group=person_group,
function=person_function,
role=person_role)
# Create assignment
assignment = person.newContent(portal_type='Assignment',
group=person_group,
......
......@@ -4,4 +4,4 @@
"""
site = context.getWebSiteValue()
section_list = site.contentValues(portal_type='Web Section', sort_on='int_index', checked_permission='View')
return filter(lambda x: x.isVisible(), section_list)
return [x for x in section_list if x.isVisible()]
......@@ -4,7 +4,7 @@
website = context.getWebSiteValue()
REQUEST = context.REQUEST
if REQUEST.has_key('portal_skin'):
context.portal_skins.clearSkinCookie()
context.portal_skins.clearSkinCookie()
REQUEST.RESPONSE.expireCookie('__ac', path='/')
msg = context.Base_translateString('You have been logged out. Thank you for using this website.')
return website.Base_redirect(form_id, keep_items = {'portal_status_message' : msg}, **kw)
......@@ -7,16 +7,16 @@
from Products.CMFCore.WorkflowCore import WorkflowException
history = {}
workflow_id_list = [workflow_id for workflow_id, workflow_state in context.getWorkflowStateItemList()]
workflow_id_list = [workflow_id for workflow_id, _ in context.getWorkflowStateItemList()]
for wf_id in workflow_id_list:
try:
history[wf_id]=context.Base_getWorkflowHistoryItemList(workflow_id=wf_id)
history[wf_id] = context.Base_getWorkflowHistoryItemList(workflow_id=wf_id)
except WorkflowException:
# some workflow don't have history
pass
# some workflow don't have history
pass
event_list = []
for worrkflow_id in history.keys():
event_list += history[worrkflow_id]
for workflow_id in history.keys():
event_list += history[workflow_id]
if sort: event_list.sort(key=lambda x:x.time, reverse=True)
return event_list
......@@ -6,11 +6,11 @@
"""
def getInlinePage(reference, language):
if reference:
page = context.getDocumentValue(reference)
if page is not None:
return page.asStrippedHTML()
return None
if reference:
page = context.getDocumentValue(reference)
if page is not None:
return page.asStrippedHTML()
return None
from Products.ERP5Type.Cache import CachingMethod
web_site_url = context.getWebSectionValue().absolute_url()
......
......@@ -9,8 +9,6 @@
Result is cached for high performance.
"""
web_site_value = context.getWebSiteValue()
web_site_url = web_site_value.absolute_url()
web_section_value = context.getWebSectionValue()
web_section_url = web_section_value.absolute_url()
context = web_section_value
......
......@@ -7,9 +7,7 @@
from zExceptions import Unauthorized
# Initialize some useful variables
request = context.REQUEST
portal = context.getPortalObject()
website = context.getWebSiteValue()
user = portal.portal_membership.getAuthenticatedMember()
user_preference = None
portal_preferences = portal.portal_preferences
......
object = state_change['object']
document = state_change['object']
workflow_tool = object.getPortalObject().portal_workflow
workflow_tool = document.getPortalObject().portal_workflow
if workflow_tool.isTransitionPossible(object, 'expire'):
object.expire()
if workflow_tool.isTransitionPossible(document, 'expire'):
document.expire()
if workflow_tool.isTransitionPossible(object, 'expire_protected'):
object.expireProtected()
if workflow_tool.isTransitionPossible(document, 'expire_protected'):
document.expireProtected()
if workflow_tool.isTransitionPossible(object, 'expire_published'):
object.expirePublished()
if workflow_tool.isTransitionPossible(document, 'expire_published'):
document.expirePublished()
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