Commit 8637adef authored by Jérome Perrin's avatar Jérome Perrin

web: fix problems reported by pylint

parent 20542e58
...@@ -12,6 +12,8 @@ Export the web page and its components to a single (m)html file. ...@@ -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. 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 zExceptions import Unauthorized
from base64 import b64encode, b64decode from base64 import b64encode, b64decode
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -20,11 +20,6 @@ ...@@ -20,11 +20,6 @@
""" """
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, ComplexQuery from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, ComplexQuery
if portal is None: portal = context.getPortalObject() 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 # Find the applicable language
if language is None: if language is None:
......
...@@ -3,7 +3,8 @@ Export the web page and its components to a single (m)html file. ...@@ -3,7 +3,8 @@ Export the web page and its components to a single (m)html file.
see Base_convertHtmlToSingleFile for documentation see Base_convertHtmlToSingleFile for documentation
""" """
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
data = context.Base_convertHtmlToSingleFile( data = context.Base_convertHtmlToSingleFile(
context.getTextContent(""), context.getTextContent(""),
allow_script=allow_script, allow_script=allow_script,
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
""" """
# Initialise result # Initialise result
sub_field_list = [] sub_field_list = []
if default_sub_field_property_dict is None:
default_sub_field_property_dict = {}
# Maximum size of the MultiListField # Maximum size of the MultiListField
default_sub_field_property_dict.update({ default_sub_field_property_dict.update({
...@@ -17,7 +19,7 @@ default_sub_field_property_dict.update({ ...@@ -17,7 +19,7 @@ default_sub_field_property_dict.update({
}) })
z = 0 z = 0
for i in range(1): for _ in range(1):
new_dict = default_sub_field_property_dict.copy() new_dict = default_sub_field_property_dict.copy()
new_dict['title'] = '&nbsp;' new_dict['title'] = '&nbsp;'
new_dict['key'] = str(z) new_dict['key'] = str(z)
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
request = context.REQUEST request = context.REQUEST
request_form = context.REQUEST.form request_form = request.form
from ZTUtils import make_query from ZTUtils import make_query
portal = context.getPortalObject() portal = context.getPortalObject()
title = context.getTitle('Unknown') title = context.getTitle('Unknown')
......
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
category -- the category to use 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 from ZODB.POSException import ConflictError
portal = context.getPortalObject() portal = context.getPortalObject()
translateString = context.Base_translateString translateString = context.Base_translateString
...@@ -20,7 +23,7 @@ def getNiceID(s): ...@@ -20,7 +23,7 @@ def getNiceID(s):
s = s.lower() s = s.lower()
s = s.split() s = s.split()
s = '-'.join(s) 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('_', '-') s = s.replace('_', '-')
return s return s
...@@ -77,7 +80,7 @@ def createWebSectionFromCategoryValue(container, category, depth, section_id=Non ...@@ -77,7 +80,7 @@ def createWebSectionFromCategoryValue(container, category, depth, section_id=Non
new_section.updateLocalRolesOnSecurityGroups() new_section.updateLocalRolesOnSecurityGroups()
except ConflictError: except ConflictError:
raise raise
except: except Exception:
failed_list.append(category.getRelativeUrl()) failed_list.append(category.getRelativeUrl())
else: else:
new_section = container[section_id] new_section = container[section_id]
......
...@@ -24,11 +24,6 @@ ...@@ -24,11 +24,6 @@
portal skins. It is recommended to use the first approach portal skins. It is recommended to use the first approach
to host multiple sites on a single ERP5Site instance. 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 # First get all the applicable references
# There might be more than one reference due to security differences # There might be more than one reference due to security differences
# (ex. a default restricted web page and a default public web page) # (ex. a default restricted web page and a default public web page)
......
request = context.REQUEST
portal = context.getPortalObject() portal = context.getPortalObject()
title = context.getTitle('Unknown') title = context.getTitle('Unknown')
translateString = context.Base_translateString translateString = context.Base_translateString
......
...@@ -10,11 +10,11 @@ ...@@ -10,11 +10,11 @@
- you need to adjust group, function and site to your needs - 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 # since the following code is just an example, we simply raise an exception so that
# it is not executed actually. # it is not executed actually.
raise NotImplementedError raise NotImplementedError
from Products.Formulator.Errors import ValidationError, FormValidationError
portal = context.getPortalObject() portal = context.getPortalObject()
translateString = context.Base_translateString translateString = context.Base_translateString
website = context.getWebSiteValue() website = context.getWebSiteValue()
...@@ -25,7 +25,7 @@ result, result_type = context.Base_edit(form_id, silent_mode=1, field_prefix='yo ...@@ -25,7 +25,7 @@ result, result_type = context.Base_edit(form_id, silent_mode=1, field_prefix='yo
# Return if not appropriate # Return if not appropriate
if result_type != 'edit': if result_type != 'edit':
return result return result
kw, encapsulated_editor_list = result kw, _ = result
# Set default values # Set default values
person_group = kw.get('group', None) person_group = kw.get('group', None)
...@@ -55,7 +55,7 @@ person.validate() ...@@ -55,7 +55,7 @@ person.validate()
#person.immediateReindexObject() #person.immediateReindexObject()
# Create default career # Create default career
career = person.newContent(portal_type='Career', person.newContent(portal_type='Career',
id='default_career', id='default_career',
group=person_group, group=person_group,
function=person_function, function=person_function,
......
...@@ -4,4 +4,4 @@ ...@@ -4,4 +4,4 @@
""" """
site = context.getWebSiteValue() site = context.getWebSiteValue()
section_list = site.contentValues(portal_type='Web Section', sort_on='int_index', checked_permission='View') 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()]
...@@ -7,16 +7,16 @@ ...@@ -7,16 +7,16 @@
from Products.CMFCore.WorkflowCore import WorkflowException from Products.CMFCore.WorkflowCore import WorkflowException
history = {} 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: for wf_id in workflow_id_list:
try: try:
history[wf_id]=context.Base_getWorkflowHistoryItemList(workflow_id=wf_id) history[wf_id] = context.Base_getWorkflowHistoryItemList(workflow_id=wf_id)
except WorkflowException: except WorkflowException:
# some workflow don't have history # some workflow don't have history
pass pass
event_list = [] event_list = []
for worrkflow_id in history.keys(): for workflow_id in history.keys():
event_list += history[worrkflow_id] event_list += history[workflow_id]
if sort: event_list.sort(key=lambda x:x.time, reverse=True) if sort: event_list.sort(key=lambda x:x.time, reverse=True)
return event_list return event_list
...@@ -9,8 +9,6 @@ ...@@ -9,8 +9,6 @@
Result is cached for high performance. 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_value = context.getWebSectionValue()
web_section_url = web_section_value.absolute_url() web_section_url = web_section_value.absolute_url()
context = web_section_value context = web_section_value
......
...@@ -7,9 +7,7 @@ ...@@ -7,9 +7,7 @@
from zExceptions import Unauthorized from zExceptions import Unauthorized
# Initialize some useful variables # Initialize some useful variables
request = context.REQUEST
portal = context.getPortalObject() portal = context.getPortalObject()
website = context.getWebSiteValue()
user = portal.portal_membership.getAuthenticatedMember() user = portal.portal_membership.getAuthenticatedMember()
user_preference = None user_preference = None
portal_preferences = portal.portal_preferences 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'): if workflow_tool.isTransitionPossible(document, 'expire'):
object.expire() document.expire()
if workflow_tool.isTransitionPossible(object, 'expire_protected'): if workflow_tool.isTransitionPossible(document, 'expire_protected'):
object.expireProtected() document.expireProtected()
if workflow_tool.isTransitionPossible(object, 'expire_published'): if workflow_tool.isTransitionPossible(document, 'expire_published'):
object.expirePublished() 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