Commit 45f71807 authored by Jérome Perrin's avatar Jérome Perrin

Make erp5_core pass coding style test

/reviewed-on !996
parents ef456975 d9f07b5b
Pipeline #7191 failed with stage
......@@ -540,7 +540,7 @@
</item>
<item>
<key> <string>round_script</string> </key>
<value> <string>Planning_roundBoundToDay</string> </value>
<value> <string>Base_roundPlanningBoxBoundToDay</string> </value>
</item>
<item>
<key> <string>sec_axis_script</string> </key>
......
......@@ -127,7 +127,7 @@
</item>
<item>
<key> <string>round_script</string> </key>
<value> <string>Planning_roundBoundToMinute</string> </value>
<value> <string>Base_roundPlanningBoxBoundToMinute</string> </value>
</item>
<item>
<key> <string>selection_name</string> </key>
......
......@@ -115,7 +115,7 @@
</item>
<item>
<key> <string>round_script</string> </key>
<value> <string>Planning_roundBoundToMinute</string> </value>
<value> <string>Base_roundPlanningBoxBoundToMinute</string> </value>
</item>
<item>
<key> <string>selection_name</string> </key>
......
......@@ -134,7 +134,7 @@
</item>
<item>
<key> <string>round_script</string> </key>
<value> <string>Planning_roundBoundToMinute</string> </value>
<value> <string>Base_roundPlanningBoxBoundToMinute</string> </value>
</item>
<item>
<key> <string>selection_name</string> </key>
......
......@@ -131,7 +131,7 @@
</item>
<item>
<key> <string>round_script</string> </key>
<value> <string>Planning_roundBoundToMinute</string> </value>
<value> <string>Base_roundPlanningBoxBoundToMinute</string> </value>
</item>
<item>
<key> <string>selection_name</string> </key>
......
......@@ -279,7 +279,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>FieldValidator_requireIfDialogConfirmed</string> </value>
<value> <string>Base_validateDialogConfirmation</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -189,7 +189,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>FieldValidator_requireIfDialogConfirmed</string> </value>
<value> <string>Base_validateDialogConfirmation</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -146,7 +146,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>FieldValidator_requireIfDialogConfirmed</string> </value>
<value> <string>Base_validateDialogConfirmation</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -146,7 +146,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>FieldValidator_requireIfDialogConfirmed</string> </value>
<value> <string>Base_validateDialogConfirmation</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -174,7 +174,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>FieldValidator_requireIfDialogConfirmed</string> </value>
<value> <string>Base_validateDialogConfirmation</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -158,7 +158,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>FieldValidator_requireIfDialogConfirmed</string> </value>
<value> <string>Base_validateDialogConfirmation</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -174,7 +174,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>FieldValidator_requireIfDialogConfirmed</string> </value>
<value> <string>Base_validateDialogConfirmation</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -146,7 +146,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>FieldValidator_requireIfDialogConfirmed</string> </value>
<value> <string>Base_validateDialogConfirmation</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -146,7 +146,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>FieldValidator_requireIfDialogConfirmed</string> </value>
<value> <string>Base_validateDialogConfirmation</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -106,7 +106,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>FieldValidator_requireIfDialogConfirmed</string> </value>
<value> <string>Base_validateDialogConfirmation</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -106,7 +106,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>FieldValidator_requireIfDialogConfirmed</string> </value>
<value> <string>Base_validateDialogConfirmation</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -37,7 +37,7 @@ class ScriptConstraint(ConstraintMixin):
portal_type = 'Script Constraint'
def _createConsistencyMessage(self, object_relative_url, message, mapping):
# XXX If I put in the right place I have TypeError: 'NoneType' object is not callable
# XXX If I put in the right place I have TypeError: 'NoneType' object is not callable
from Products.ERP5Type.ConsistencyMessage import ConsistencyMessage
return ConsistencyMessage(self,
object_relative_url=object_relative_url,
......
......@@ -107,23 +107,8 @@ def getExcerptText(context, txt, sw, tags, trail, maxlines):
txt = txt.replace('-',' - ') # to find hyphenated occurrences
txt = txt.replace(',',', ')
txt = txt.replace(';','; ')
r = re.compile('\s+')
r = re.compile(r'\s+')
txt = re.sub(r,' ',txt)
text = ' '.join(txt.split('\n')).split(' ') # very rough tokenization
return [p for p in generateParts(context,text,sw,tags,trail,maxlines)]
if __name__=='__main__':
sw='pricing priority right acting proportion'
txt=' '.join([l.strip() for l in open('offer.txt').readlines()])
# configuration
tags=('<b>','</b>')
trail=5
maxlines=5
for p in getExcerptText(None,txt,sw,tags,trail,maxlines):
print p
# vim: filetype=python syntax=python shiftwidth=2
......@@ -52,7 +52,6 @@ def getDocumentGroupByWorkflowStateList(self, form_id='', **kw):
doc.getPortalTypeName())
return get_url
request = self.REQUEST
portal = self.getPortalObject()
Base_translateString = portal.Base_translateString
wf_tool = portal.portal_workflow
......
......@@ -45,9 +45,7 @@
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W: 55, 2: Unused variable \'request\' (unused-variable)</string>
</tuple>
<tuple/>
</value>
</item>
<item>
......
......@@ -14,7 +14,6 @@
from Products.ZSQLCatalog.zsqlbrain import ZSQLBrain
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
from ZTUtils import make_query
from Products.CMFCore.utils import getToolByName
from Products.ERP5Type.Message import translateString
from ComputedAttribute import ComputedAttribute
......
......@@ -45,9 +45,7 @@
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W: 17, 0: Unused getToolByName imported from Products.CMFCore.utils (unused-import)</string>
</tuple>
<tuple/>
</value>
</item>
<item>
......
from AccessControl import getSecurityManager
from zExceptions import Unauthorized
if REQUEST is not None: # Cheap "do not call from URL" protection - not that the session key is secret
raise Unauthorized
......
from ZTUtils import make_query
object = brain.getObject()
if object is None:
obj = brain.getObject()
if obj is None:
return None
url = context.absolute_url()
method = context.getReportMethodId('Alarm_viewReport')
kw = { 'active_process' : 'portal_activities/%s' % object.id,
kw = { 'active_process' : 'portal_activities/%s' % obj.id,
'reset' : '1',
}
......
......@@ -104,7 +104,6 @@ except FormValidationError, validation_errors:
can_redirect = 1
MARKER = [] # A recognisable default value. Use with 'is', not '=='.
listbox_id_list = [] # There should not be more than one listbox - but this give us a way to check.
file_id_list = [] # For uploaded files.
for field in form.get_fields():
k = field.id
v = request.get(k, MARKER)
......@@ -151,7 +150,7 @@ if len(listbox_id_list):
if hasattr(kw, 'previous_md5_object_uid_list'):
selection_list = context.portal_selections.callSelectionFor(kw['list_selection_name'], context=context)
if selection_list is not None:
object_uid_list = map(lambda x:x.getObject().getUid(), selection_list)
object_uid_list = [x.getObject().getUid() for x in selection_list]
error = context.portal_selections.selectionHasChanged(kw['previous_md5_object_uid_list'], object_uid_list)
if error:
error_message = context.Base_translateString("Sorry, your selection has changed.")
......@@ -167,7 +166,7 @@ listbox_uid = kw.get('listbox_uid', None)
# In such cases, we must not try to update a non-existing selection.
if listbox_uid is not None and kw.has_key('list_selection_name'):
uids = kw.get('uids')
selected_uids = context.portal_selections.updateSelectionCheckedUidList(
context.portal_selections.updateSelectionCheckedUidList(
kw['list_selection_name'],
listbox_uid, uids)
# Remove values which doesn't work with make_query.
......
# Updates attributes of an Zope document
# which is in a class inheriting from ERP5 Base
from Products.Formulator.Errors import ValidationError, FormValidationError
from Products.Formulator.Errors import FormValidationError
request = context.REQUEST
field_sort_type = request.form.get('field_sort_type', None)
......
# Updates attributes of an Zope document
# which is in a class inheriting from ERP5 Base
from Products.Formulator.Errors import ValidationError, FormValidationError
from Products.Formulator.Errors import FormValidationError
request=context.REQUEST
......
# This scripts allows to update a list so that it
# can be displayed correctly in a graph
# The list given have to be of the forme:
# list = [[Datetime(),value (,value)*],([Datetime(),value (,value)*])*]
list.sort()
# Check if there is any none value, and replace it by 0
formated_list = []
if len(list) >= 1:
for i in range(len(list)):
for index_value in range(1,len(list[0])):
if list[i][index_value]==None:
list[i][index_value]=0
formated_list.append(list[0])
for i in range(1,len(list)):
nb_days = int(list[i][0]-list[i-1][0])
for day in range(1,nb_days):
formated_list.append([list[i-1][0]+day])
for nb_value in range(1,len(list[i-1])):
formated_list[len(formated_list)-1].append(list[i-1][nb_value])
formated_list.append(list[i])
return formated_list
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>list=[]</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_convertDateListToChartList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
# This scripts allows to update a list so that it
# converts variation on a quantity to the quantity itself
# ie, if list=[[DateTime('09/10/2003'),+4],[DateTime('09/19/2003'),-8]],
# and initial_quantity = [3]
# result: [[DateTime('2003/09/10'), 7], [DateTime('2003/09/19'), -1]]
# The list given have to be of the forme:
# list = [[Datetime(),value (,value)*],([Datetime(),value (,value)*])*]
# The initial_quantity have to be like this :
# initial_quantity = [value (,value)*]
list.sort()
quantity_list = []
#if type(initial_quantity) is type(1):
# initial_quantity = [initial_quantity]
if len(list) >= 1 and (len(list[0])-1)==len(initial_quantity):
quantity_list.append([list[0][0]])
for i in range(1,len(list[0])):
if list[0][i]==None:
list[0][i]=0
quantity_list[0].append(initial_quantity[i-1] + list[0][i])
for value in range(1,len(list)):
quantity_list.append([list[value][0]])
for i in range(1,len(list[0])):
if list[value][i]==None:
list[value][i]=0
quantity_list[value].append(quantity_list[value-1][i] + list[value][i])
return quantity_list
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>list=[],initial_quantity=[]</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_convertVariationListToQuantityList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -2,7 +2,6 @@
this type cannot be added in the container.
"""
Base_translateString = context.Base_translateString
REQUEST=context.REQUEST
parent = context.getParentValue()
allowed_type_list = parent.getVisibleAllowedContentTypeList()
......
......@@ -19,11 +19,11 @@ for v in values:
# We should not edit the id field
# because the object which is created is not attached to a
# module yet
id = v
id_ = v
else:
id=str(module.generateNewId())
module.invokeFactory(type_name=portal_type,id=id)
new_ob = module.get(id)
id_ = str(module.generateNewId())
module.invokeFactory(type_name=portal_type, id=id_)
new_ob = module.get(id_)
kw = {}
if catalog_index != 'id':
kw[catalog_index] = v
......@@ -34,59 +34,3 @@ for v in values:
o.setValue(base_category, ref_list, portal_type=[portal_type])
return request[ 'RESPONSE' ].redirect( return_url )
try:
# Validate the form
form = getattr(context,form_id)
form.validate_all_to_request(request)
my_field = None
# Find out which field defines the relation
for f in form.get_fields():
if f.has_value( 'base_category'):
if f.get_value('base_category') == base_category:
k = f.id
v = getattr(request,k,None)
if v != context.getProperty(k[3:]):
my_field = f
if my_field:
kw ={}
kw[my_field.get_value('catalog_index')] = request.get( my_field.id, None)
context.portal_selections.setSelectionParamsFor('Base_viewRelatedObjectList', kw.copy())
kw['base_category'] = base_category
kw['portal_type'] = my_field.get_value('portal_type')
request.set('base_category', base_category)
request.set('portal_type', my_field.get_value('portal_type'))
request.set('form_id', 'Base_viewRelatedObjectList')
request.set(my_field.get_value('catalog_index'), request.get( my_field.id, None))
relation_list = context.portal_catalog(**kw)
if len(relation_list) > 0:
return context.Base_viewRelatedObjectList( REQUEST=request )
else:
request.set('catalog_index', my_field.get_value('catalog_index'))
request.set('relation_values', request.get( my_field.id, None))
return context.Base_viewCreateRelationDialog( REQUEST=request )
pass
# context.newRelation(base_category, my_field.get_value('portal_type'))
except FormValidationError, validation_errors:
# Pack errors into the request
field_errors = form.ErrorFields(validation_errors)
request.set('field_errors', field_errors)
return form(request)
else:
message = 'Relation+Unchanged.'
if not selection_index:
redirect_url = '%s/%s?%s' % ( o.absolute_url()
, form_id
, 'portal_status_message=%s' % message
)
else:
redirect_url = '%s/%s?selection_index=%s&selection_name=%s&%s' % ( o.absolute_url()
, form_id
, selection_index
, selection_name
, 'portal_status_message=%s' % message
)
request[ 'RESPONSE' ].redirect( redirect_url )
......@@ -57,7 +57,7 @@ def editListBox(listbox_field, listbox):
if listbox is not None:
global_property_dict = {}
if listbox_field.has_value('global_attributes'):
hidden_attribute_list = map(lambda x:x[0], listbox_field.get_value('global_attributes'))
hidden_attribute_list = [x[0] for x in listbox_field.get_value('global_attributes')]
for hidden_attribute in hidden_attribute_list:
global_property_dict[hidden_attribute] = getattr(request, hidden_attribute, None)
for item_url, listbox_item_dict in listbox.items():
......@@ -129,10 +129,10 @@ def editMatrixBox(matrixbox_field, matrixbox):
columns = matrixbox_field.get_value('columns')
tabs = matrixbox_field.get_value('tabs')
column_ids = map(lambda x: x[0], columns)
line_ids = map(lambda x: x[0], lines)
tab_ids = map(lambda x: x[0], tabs)
extra_dimension_category_list_list = [[category for category, label in dimension_list] for dimension_list in extra_dimension_list_list]
column_ids = [x[0] for x in columns]
line_ids = [x[0] for x in lines]
tab_ids = [x[0] for x in tabs]
extra_dimension_category_list_list = [[category for category, _ in dimension_list] for dimension_list in extra_dimension_list_list]
# There are 3 cases
# Case 1: we do 1 dimensional matrix
......@@ -250,8 +250,6 @@ server_physical_path = context.getPhysicalPath()
server_physical_path = list(server_physical_path)
server_url = request["SERVER_URL"]
server_physical_path.insert(0, server_url)
#calculate direct the url instead of using absolute_url
new_url = '/'.join(server_physical_path)
# for web mode, we should use 'view' instead of passed form_id
# after 'Save & View'.
......
# Updates relation of an ERP5 document
from Products.ERP5Type.Message import Message
from Products.Formulator.Errors import ValidationError
from Products.ERP5Form.MultiRelationField import SUB_FIELD_ID
if listbox_uid is not None:
selection_tool = context.getPortalObject().portal_selections
selected_uids = selection_tool.updateSelectionCheckedUidList(
selection_tool.updateSelectionCheckedUidList(
selection_name, listbox_uid, uids)
uids = selection_tool.getSelectionCheckedUidsFor(selection_name)
......
from Products.ERP5Type.Document import newTempDomain
domain_list=[]
request = context.REQUEST
filter = {}
filter_ = {}
try:
# first, try to get form_id from the request
......@@ -12,7 +11,7 @@ except KeyError:
if listbox is not None:
portal_type_list = [x[0] for x in listbox.get_value('portal_types')]
filter['portal_type'] = portal_type_list
filter_['portal_type'] = portal_type_list
if depth == 0:
parent_obj = request['here']
......@@ -22,7 +21,7 @@ else:
parent_url = parent.getProperty('parent_url')
parent_obj = context.restrictedTraverse(parent_url)
for obj in parent_obj.contentValues(filter=filter):
for obj in parent_obj.contentValues(filter=filter_):
domain = parent.generateTempDomain(id='%s_%s' % (depth, obj.getId()))
domain.edit(title=obj.getTitle(),
parent_url=obj.getRelativeUrl(),
......
......@@ -10,4 +10,4 @@ if include_letters:
character_set = '%s%s' %(character_set, letters)
if include_digits:
character_set = '%s%s' %(character_set, digits)
return ''.join([choice(character_set) for i in range(int(string_length))])
return ''.join([choice(character_set) for _ in range(int(string_length))])
......@@ -21,12 +21,6 @@ current_date = DateTime(year, 1, 1)
default_link_url ='setLanePath?form_id=%s&list_selection_name=%s' %(
form_id, selection_name)
# Define date format using user Preferences
date_order = portal.portal_preferences.getPreferredDateOrder()
date_format = dict(ymd='%m/%d',
dmy='%d/%m',
mdy='%m/%d').get(date_order, '%m/%d')
category_list = []
if depth == 0:
# getting list of months
......
......@@ -88,13 +88,12 @@ if not (content_type.startswith('application/vnd.sun.xml')
tmp_ooo.edit(data=import_file.read(),
content_type=content_type)
tmp_ooo.convertToBaseFormat()
ignored, import_file_content = tmp_ooo.convert('ods')
_, import_file_content = tmp_ooo.convert('ods')
parser.openFromString(str(import_file_content))
else:
parser.openFile(import_file)
# Extract tables from the speadsheet file
filename = parser.getFilename()
spreadsheet_list = parser.getSpreadsheetsMapping(no_empty_lines=True)
......@@ -128,8 +127,6 @@ for table_name in spreadsheet_list.keys():
else:
# If there is a new column with a header and the path definition has
# started, that seems the path definition has ended
if 'path_0' in property_map.values():
path_index == None # FIXME: useless statement, but what was the original intention ??
property_map[column_index] = column_id.encode('utf8')
column_index += 1
......
if context.REQUEST.has_key('workflow_action'): # We are on a workflow transition
help = '%s#%s' % (getattr(getattr(context, form_id), 'form_action'),context.REQUEST['workflow_action'])
help_relative_url = '%s#%s' % (getattr(getattr(context, form_id), 'form_action'),context.REQUEST['workflow_action'])
elif action is not None:
help = '%s#%s' % (context.getPortalTypeName(), action)
help_relative_url = '%s#%s' % (context.getPortalTypeName(), action)
elif form_id is not None:
help = '%s_%s' % (context.getPortalTypeName(), form_id)
help_relative_url = '%s_%s' % (context.getPortalTypeName(), form_id)
else:
help = context.getPortalTypeName()
return '%s/%s' % (context.portal_preferences.getPreferredHtmlStyleDocumentationBaseUrl(), help)
help_relative_url = context.getPortalTypeName()
return '%s/%s' % (context.portal_preferences.getPreferredHtmlStyleDocumentationBaseUrl(), help_relative_url)
if default_sub_field_property_dict is None:
default_sub_field_property_dict = {}
# Define a dictionary where we store the subfields to display.
sub_field_dict = {}
split_depth = 1
......
......@@ -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>
......
if default_sub_field_property_dict is None:
default_sub_field_property_dict = {}
# Define a dictionary where we store the subfields to display.
sub_field_dict = {}
split_depth = 1
......
......@@ -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>
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>portal_type=[\'Organisation\'], validation_state=(\'validated\', \'draft\'), base_category=None</string> </value>
<value> <string>portal_type=(\'Organisation\', ), validation_state=(\'validated\', \'draft\'), base_category=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>portal_type= [], limit=None, **kw</string> </value>
<value> <string>portal_type=(), limit=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -8,14 +8,14 @@ translation_map = { "a": ['\xe0']
}
clean_id = ''
if string == None:
if s is None:
return None
string = string.lower()
string = string.strip()
s = s.lower()
s = s.strip()
# oocalc inserts some strange chars when you press - key in a text cell.
# Following line is a workaround for this, because \u2013 does not exist in latin1
string = string.replace(u'\u2013', '-')
for char in string.encode('iso8859_1'):
s = s.replace(u'\u2013', '-')
for char in s.encode('iso8859_1'):
if char == '_' or char.isalnum():
clean_id += char
elif char.isspace() or char in ('+', '-'):
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>string=None</string> </value>
<value> <string>s=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>selection=None, argument_name_list=[]</string> </value>
<value> <string>selection=None, argument_name_list=()</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
# controls the visibility of "developper mode" links in ERP5 web interface
# (edit form, edit field, edit portal type, ...) for object
if object is None:
object = context
if obj is None:
obj = context
return context.portal_preferences.getPreferredHtmlStyleDevelopperMode() and context.portal_membership.checkPermission('View management screens', object)
return context.portal_preferences.getPreferredHtmlStyleDevelopperMode() and context.portal_membership.checkPermission('View management screens', obj)
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>object=None</string> </value>
<value> <string>obj=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -5,7 +5,7 @@ history_name_list = ['building_history', ' installation_history', 'history']
history = {}
portal_workflow = context.getPortalObject().portal_workflow
workflow_id_list = [workflow_id for workflow_id, workflow_state in context.getWorkflowStateItemList()]
workflow_id_list = [x[0] for x in context.getWorkflowStateItemList()]
for history_name in history_name_list:
......@@ -16,7 +16,7 @@ for history_name in history_name_list:
list_history_item = portal_workflow.getInfoFor(ob=context, name=history_name, wf_id=wf_id)
except ConflictError:
raise
except:
except Exception:
pass
if list_history_item not in ((), None):
......
request = context.REQUEST
from Products.ERP5Type.Document import newTempBase
from Products.ERP5Type.Document import newTempMappedValue
from Products.ERP5Type.Utils import getTranslationStringWithContext
from AccessControl import getSecurityManager
......@@ -12,7 +10,7 @@ result = []
i = 1
portal_object = context.getPortalObject()
portal_workflow = portal_object.portal_workflow
workflow_id_list = [x for x, y in context.getWorkflowStateItemList()]
workflow_id_list = [x[0] for x in context.getWorkflowStateItemList()]
if not workflow_id in workflow_id_list:
return []
......@@ -31,12 +29,8 @@ def getActorName(actor):
# Get history
# XXX Compatibility
for history_name in ['history', 'building_history', 'installation_history']:
workflow_item_list = portal_workflow.getInfoFor(ob=context,
name='history', wf_id=workflow_id)
if workflow_item_list != []:
break
workflow_item_list = portal_workflow.getInfoFor(
ob=context, name='history', wf_id=workflow_id)
wf_state_var = portal_workflow[workflow_id].variables.getStateVar()
wf_states = portal_workflow[workflow_id].states
......
......@@ -5,6 +5,8 @@
in such way that it is possible to select multiple
categories for the same document )
"""
if default_sub_field_property_dict is None:
default_sub_field_property_dict = {}
# Initialise result
sub_field_list = []
......
......@@ -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>
......
from ZTUtils import make_query
request=context.REQUEST
form = getattr(context,form_id)
field = form.get_field(field_id)
base_category = field.get_value('base_category')
portal_type = map(lambda x:x[0],field.get_value('portal_type'))
portal_type = [x[0] for x in field.get_value('portal_type')]
kw = {}
for k, v in field.get_value('parameter_list') :
kw[k] = v
......@@ -16,7 +14,7 @@ if len(jump_reference_list)==1:
jump_reference = jump_reference_list[0]
return jump_reference.Base_redirect()
else:
selection_uid_list = map(lambda x:x.getUid(),jump_reference_list) or None
selection_uid_list = [x.getUid() for x in jump_reference_list] or None
kw = {'uid': selection_uid_list}
# We need to reset the selection. Indeed, some sort columns done in another
# jump could be meaningless for this particular jump. The consequence could
......
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Planning_roundBoundToDay</string> </value>
<value> <string>Base_roundPlanningBoxBoundToDay</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Planning_roundBoundToInt</string> </value>
<value> <string>Base_roundPlanningBoxBoundToInt</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Planning_roundBoundToMinute</string> </value>
<value> <string>Base_roundPlanningBoxBoundToMinute</string> </value>
</item>
</dictionary>
</pickle>
......
from Products.Formulator.Errors import ValidationError, FormValidationError
from ZTUtils import make_query
request=context.REQUEST
if isinstance(list_form_id,tuple):
list_form_id = list_form_id[0]
# The type list is not working with isinstance, I have do do this bad hack
if hasattr(list_form_id,'sort'):
list_form_id = list_form_id[0]
module_name = context.getId()
try:
# Validate the form
form = getattr(context,dialog_id)
form.validate_all_to_request(request)
kw = {}
for f in form.get_fields():
k = f.id
# XXX Remove your_ parameters...
k = k[5:]
v = getattr(request,k,None)
if v is not None and k != 'list_form_id' :
kw[k] = v
if list_method_id is not None and list_method_id != '' :
kw['list_method_id'] = list_method_id
url_params_string = make_query(kw)
# raise str(kw), url_params_string
except FormValidationError, validation_errors:
# Pack errors into the request
field_errors = form.ErrorFields(validation_errors)
request.set('field_errors', field_errors)
return form(request)
if url_params_string != '':
redirect_url = '%s/%s?%s' % ( context.absolute_url()
, list_form_id
, url_params_string
)
else:
redirect_url = '%s/%s' % ( context.absolute_url()
, list_form_id
)
return request.RESPONSE.redirect( redirect_url )
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>form_id,dialog_id,list_form_id,list_method_id=\'\'</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_searchHandler</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -11,6 +11,6 @@ def generic_sort(a,b):
return result
return result
unordered_list = map(lambda x: x.getObject(), unordered_list)
unordered_list = [x.getObject() for x in unordered_list]
unordered_list.sort(generic_sort)
return unordered_list
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>unordered_list=[], sort_order=()</string> </value>
<value> <string>unordered_list, sort_order=()</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
from string import zfill
request = context.REQUEST
from string import zfill
if kw.get('update', False):
# Ensure ERP5JS correctly refresh the page
request.RESPONSE.setStatus(400)
......
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>FieldValidator_requireIfDialogConfirmed</string> </value>
<value> <string>Base_validateDialogConfirmation</string> </value>
</item>
</dictionary>
</pickle>
......
from Products.ERP5Type.Log import log
portal = container.getPortalObject()
if not(id_value.endswith(portal.restrictedTraverse(REQUEST.object_path)\
.getIdAsReferenceSuffix())):
......
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PropertySheetChild_validateIDField</string> </value>
<value> <string>Base_validateIDAsReferenceSuffix</string> </value>
</item>
</dictionary>
</pickle>
......
from Products.Formulator.Errors import ValidationError, FormValidationError
from Products.Formulator.Errors import FormValidationError
from ZTUtils import make_query
portal = context.getPortalObject()
Base_translateString = portal.Base_translateString
......@@ -46,8 +46,6 @@ def getOrderedUids(uids, values, catalog_index):
uids.append(value_to_uid[value])
return uids
field.get_value('base_category')
try:
# Validate the form
form = getattr(context,form_id)
......@@ -71,7 +69,6 @@ try:
new_value = v
base_category = f.get_value( 'base_category')
if my_field and base_category is not None:
empty_list = 0
if new_value == '':
new_value = []
if same_type(new_value,'a'):
......@@ -90,7 +87,7 @@ try:
if checkSameKeys(new_value, old_value):
# Reorder keys
same_keys = 1
portal_type = map(lambda x:x[0],my_field.get_value('portal_type'))
portal_type = [x[0] for x in my_field.get_value('portal_type')]
# We work with strings - ie. single values
kw ={}
kw[my_field.get_value('catalog_index')] = new_value
......@@ -103,7 +100,7 @@ try:
request.set('field_id', my_field.id)
previous_uids = o.getValueUidList(base_category, portal_type=portal_type)
relation_list = context.portal_catalog(**kw)
relation_uid_list = map(lambda x: x.uid, relation_list)
relation_uid_list = [x.uid for x in relation_list]
uids = []
for uid in previous_uids:
if uid in relation_uid_list:
......
......@@ -13,10 +13,10 @@ from pprint import pformat
ret = '<html><body><table width=100%>\n'
dict = context.showDict().items()
dict.sort()
property_dict = context.showDict().items()
property_dict.sort()
i = 0
for k,v in dict:
for k,v in property_dict:
if (i % 2) == 0:
c = '#88dddd'
else:
......
......@@ -540,7 +540,7 @@
</item>
<item>
<key> <string>round_script</string> </key>
<value> <string>Planning_roundBoundToDay</string> </value>
<value> <string>Base_roundPlanningBoxBoundToDay</string> </value>
</item>
<item>
<key> <string>sec_axis_script</string> </key>
......
......@@ -116,7 +116,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>PropertySheetChild_validateIDField</string> </value>
<value> <string>Base_validateIDAsReferenceSuffix</string> </value>
</item>
</dictionary>
</pickle>
......
REQUEST=context.REQUEST
RESPONSE=REQUEST.RESPONSE
return context.portal_templates.save(context, REQUEST=REQUEST)
......@@ -72,12 +72,10 @@ for base_category, category_list in category_list_spreadsheet_dict.iteritems():
except ValueError:
category_id = category_path
container = portal_categories
is_base_category = True
category_type = 'Base Category'
category_type_property_id_set = base_category_property_id_set
else:
container = resolveCategory(container_path)
is_base_category = False
category_type = 'Category'
category_type_property_id_set = category_property_id_set
try:
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>import_file, update_existing_property=False, keep_existing_category=True, detailed_report=False, simulation_mode=False, displayed_report=[], effective_date=None, expiration_date=None, existing_category_list=\'keep\', create_local_property=False, **kw</string> </value>
<value> <string>import_file, update_existing_property=False, keep_existing_category=True, detailed_report=False, simulation_mode=False, displayed_report=(), effective_date=None, expiration_date=None, existing_category_list=\'keep\', create_local_property=False, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -2,7 +2,7 @@ from Products.ERP5Type.Log import log
# this script is no longer needed.
log('Category_getSortedCategoryChildValueList', 'use getCategoryChildValueList method')
value_list = filter(lambda o: o.getRelativeUrl() != context.getRelativeUrl(),context.getCategoryChildValueList())
value_list = [o for o in context.getCategoryChildValueList() if o.getRelativeUrl() != context.getRelativeUrl()]
sort_id='int_index'
value_list.sort(key=lambda x: x.getProperty(sort_id))
return value_list
......@@ -42,8 +42,8 @@ if depth == maximum_depth and id_list:
if recursive:
for subdocument in document.objectValues():
recurse(subdocument)
for id in id_list:
recurse(document[id])
for id_ in id_list:
recurse(document[id_])
if active_process is None:
return error_list
if error_list:
......@@ -84,8 +84,8 @@ else:
active_script = getattr(activate(priority=4), script.id)
if depth < maximum_depth:
relative_url = relative_url and relative_url + '/' or ''
for id in id_list:
active_script(relative_url=relative_url + id, **kw)
for id_ in id_list:
active_script(relative_url=relative_url + id_, **kw)
else:
kw['relative_url'] = relative_url
for i in xrange(0, len(id_list), packet):
......
......@@ -85,13 +85,13 @@ def checkField(folder, form, field):
a = template_field.getListMethodName()
path += '/listbox'
for x in 'columns', 'all_columns':
for id, title in field.get_value(x):
for id_, title in field.get_value(x):
error_message += checkTitle(path, x, title, field, form)
if a not in (None, "portal_catalog", "searchFolder", "objectValues",
"contentValues", "ListBox_initializeFastInput"):
if not a.endswith('List'):
if 0:
error_message += "%s : %s : %r Bad Naming Convention\n" % (path, id, a)
error_message += "%s : %s : %r Bad Naming Convention\n" % (path, id_, a)
return error_message
def isListBox(field):
......@@ -107,7 +107,7 @@ titlecase_sub = re.compile(r"[A-Za-z]+('[A-Za-z]+)?").sub
titlecase_repl = lambda mo: mo.group(0)[0].upper() + mo.group(0)[1:].lower()
titlecase = lambda s: titlecase_sub(titlecase_repl, s)
def checkTitle(path, id, title, field=None, form=None):
def checkTitle(path, id_, title, field=None, form=None):
"""
Generic function that test the validity of a title.
"""
......@@ -115,11 +115,11 @@ def checkTitle(path, id, title, field=None, form=None):
if (form is not None and form.pt not in ('form_dialog', 'folder_workflow_action_dialog')) or form is None:
if (field is not None and not field.get_value('hidden') and \
(title is None or len(title.strip()) == 0)) or (field is None and (title is None or len(title.strip()) == 0)):
return "%s : %s : can't be empty\n" % (path, id)
return "%s : %s : can't be empty\n" % (path, id_)
for c in title:
if c.lower() not in ALLOWED_CHARS:
return "%s : %s : %r character not allowed\n" % (path, id, c)
return "%s : %s : %r character not allowed\n" % (path, id_, c)
title = re.sub(re.compile(r"\b(" + "|".join(re.escape(x) for x in SENTENCE_PART_SET) + r")\b"), "", title)
......@@ -132,22 +132,22 @@ def checkTitle(path, id, title, field=None, form=None):
if word.upper() in ABBREVIATION_WORD_SET:
if not word.isupper():
error_message += '%s : %s : %r is not upper case even though it is an abbriviation\n' % (path, id, word)
error_message += '%s : %s : %r is not upper case even though it is an abbriviation\n' % (path, id_, word)
elif word.endswith('s') and word[:-1].upper() in ABBREVIATION_WORD_SET:
if not word[:-1].isupper():
error_message += '%s : %s : %r is not upper case even though it is an abbriviation\n' % (path, id, word)
error_message += '%s : %s : %r is not upper case even though it is an abbriviation\n' % (path, id_, word)
elif "-" in word and word.split("-")[0].upper() in ABBREVIATION_WORD_SET:
if not word.split("-")[0].isupper():
error_message += '%s : %s : %r is not upper case even though it is an abbriviation\n' % (path, id, word)
error_message += '%s : %s : %r is not upper case even though it is an abbriviation\n' % (path, id_, word)
else:
if word.lower() in CLOSED_CLASS_WORD_SET and word != word_list[0] :
if (word.capitalize()== word or titlecase(word)== word):
error_message += '%s : %s : %r is a closed-class word and should not be titlecased\n' % (path, id, word)
error_message += '%s : %s : %r is a closed-class word and should not be titlecased\n' % (path, id_, word)
elif (word.capitalize()!= word and titlecase(word)!= word) and \
word not in LOWERCASE_WORD_SET and word not in SPECIALCASE_WORD_SET and word not in CLOSED_CLASS_WORD_SET :
error_message += '%s : %s : %r is not titlecased\n' % (path, id, word)
error_message += '%s : %s : %r is not titlecased\n' % (path, id_, word)
if len(word_list) > 1 and word_list[-1].upper() == 'LIST' and word_list[-2].upper() != 'PACKING':
error_message += '%s : %s : %r is a jargon\n' % (path, id, title)
error_message += '%s : %s : %r is a jargon\n' % (path, id_, title)
return error_message
......
help = context.getPortalTypeName()
help_topic = context.getPortalTypeName()
if workflow_action is not None: # First, the workflow transition case.
help = '%s_%s' % (help, workflow_action)
help_topic = '%s_%s' % (help_topic, workflow_action)
elif current_action is not None: # Then, we are able to get the action.
help = '%s_%s' % (help, current_action['id'])
help_topic = '%s_%s' % (help_topic, current_action['id'])
elif current_form_id is not None: # Otherwise, get the form we are in.
help = '%s_%s' % (help, current_form_id)
return '%s/%s' % (context.portal_preferences.getPreferredHtmlStyleDocumentationBaseUrl(), help)
help_topic = '%s_%s' % (help_topic, current_form_id)
return '%s/%s' % (context.portal_preferences.getPreferredHtmlStyleDocumentationBaseUrl(), help_topic)
......@@ -4,7 +4,6 @@ Content will be created in the appropriate module. It is
intended to be called from the user interface only.
"""
translateString = context.Base_translateString
request = context.REQUEST
# Create the new content in appropriate module
portal_object = context.getPortalObject()
......
......@@ -10,23 +10,23 @@ nb_types = {}
for error in error_list:
# We count the number of each portal type
if error[1]=='portal_type':
type = error[3]
if nb_types.has_key(type):
nb_types[type] = nb_types[type] + 1
portal_type = error[3]
if nb_types.has_key(portal_type):
nb_types[portal_type] = nb_types[portal_type] + 1
else:
nb_types[type] = 1
nb_types[portal_type] = 1
else:
#print error
return_list.append(error)
for type in nb_types.keys():
for portal_type in nb_types.keys():
# Find the number of each portal type in the catalog
count_result = context.portal_catalog.countResults(portal_type=type)
count_result = context.portal_catalog.countResults(portal_type=portal_type)
nb_catalog = count_result[0][0]
if nb_types[type] != nb_catalog:
if nb_types[portal_type] != nb_catalog:
message = "XXX Warning for %s: there is %i lines in the catalog instead of %i" % \
(type,nb_catalog,nb_types[type])
(portal_type, nb_catalog, nb_types[portal_type])
return_list.append(('Count Error', 'PortalRoot_reindexAll',1,message))
#else: print "%s: %i" % (type,nb_types[type])
#else: print "%s: %i" % (portal_type,nb_types[portal_type])
return return_list
......@@ -13,7 +13,7 @@ unindex_count = 0
for candidate in candidate_list:
path = candidate['path']
try:
object = portal.restrictedTraverse(path)
obj = portal.restrictedTraverse(path)
except KeyError:
# Object is unreachable, remove it from catalog
# Use SQLQueue because all activities are triggered on the same object,
......@@ -21,7 +21,7 @@ for candidate in candidate_list:
catalog.activate(activity="SQLQueue").unindexObject(uid=candidate['uid'])
unindex_count += 1
else:
object.reindexObject()
obj.reindexObject()
reindex_count += 1
print '%s object reindexed, %s object unindexed' % (reindex_count, unindex_count)
......
activate_kw = {"tag" : tag}
folder = context.restrictedTraverse(folder_path)
method = getattr(context, method)
for id in id_list:
ob = folder.get(id)
for id_ in id_list:
ob = folder.get(id_)
new_id = method(ob)
ob.setDefaultActivateParameterDict(activate_kw)
ob.setId(new_id)
......@@ -11,9 +11,9 @@ z_catalog_translation_list = sql_catalog.z_catalog_translation_list
def catalog_translation_list(object_list):
parameter_dict = {}
for i in object_list:
for property in ('language', 'message_context', 'portal_type',
for property_ in ('language', 'message_context', 'portal_type',
'original_message', 'translated_message'):
parameter_dict.setdefault(property, []).append(i[property])
parameter_dict.setdefault(property_, []).append(i[property_])
z_catalog_translation_list(**parameter_dict)
# Translate every workflow state in the context of the state variable
......
......@@ -10,10 +10,10 @@ If unsure, you should use ERP5Type_getSecurityCategoryFromContent.
"""
category_list = []
if object is None:
if ob is None:
return []
for base_category in base_category_list:
category_list.append({base_category: object.getAcquiredCategoryMembershipList(base_category)})
category_list.append({base_category: ob.getAcquiredCategoryMembershipList(base_category)})
return category_list
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>base_category_list, user_name, object, portal_type</string> </value>
<value> <string>base_category_list, user_name, ob, portal_type</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
......
......@@ -3,4 +3,4 @@ log("ERP5Type_getSecurityCategoryFromArrow is deprecated, "
"use ERP5Type_getSecurityCategoryFromContent instead")
return context.ERP5Type_getSecurityCategoryFromContent(
base_category_list, user_name, object, portal_type)
base_category_list, user_name, ob, portal_type)
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>base_category_list, user_name, object, portal_type</string> </value>
<value> <string>base_category_list, user_name, ob, portal_type</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
......
......@@ -19,7 +19,7 @@ The parameters are
base_category_list -- list of category values we need to retrieve
user_name -- string obtained from getSecurityManager().getUser().getId()
object -- object which we want to assign roles to
ob -- object which we want to assign roles to
portal_type -- portal type of object
NOTE: for now, this script requires proxy manager
......@@ -27,10 +27,10 @@ NOTE: for now, this script requires proxy manager
category_list = []
if object is None:
if ob is None:
return []
for base_category in base_category_list:
category_list.append({base_category: object.getCategoryMembershipList(base_category)})
category_list.append({base_category: ob.getCategoryMembershipList(base_category)})
return category_list
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>base_category_list, user_name, object, portal_type</string> </value>
<value> <string>base_category_list, user_name, ob, portal_type</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
......
......@@ -14,7 +14,7 @@ The parameters are
base_category_list -- list of category values we need to retrieve
user_name -- string obtained from getSecurityManager().getUser().getId()
object -- object which we want to assign roles to
ob -- object which we want to assign roles to
portal_type -- portal type of object
NOTE: for now, this script requires proxy manager
......@@ -22,10 +22,10 @@ NOTE: for now, this script requires proxy manager
category_list = []
if object is None:
if ob is None:
return []
for base_category in base_category_list:
category_list.append({base_category: object.getRelativeUrl()})
category_list.append({base_category: ob.getRelativeUrl()})
return category_list
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>base_category_list, user_name, object, portal_type</string> </value>
<value> <string>base_category_list, user_name, ob, portal_type</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -14,7 +14,7 @@ The parameters are
base_category_list -- list of category values we need to retrieve
user_name -- string obtained from getSecurityManager().getUser().getId()
object -- object which we want to assign roles to
ob -- object which we want to assign roles to
portal_type -- portal type of object
NOTE: for now, this script requires proxy manager
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>base_category_list, user_name, object, portal_type</string> </value>
<value> <string>base_category_list, user_name, ob, portal_type</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -19,7 +19,7 @@ The parameters are
base_category_list -- list of category values we need to retrieve
user_name -- string obtained from getSecurityManager().getUser().getId()
object -- object which we want to assign roles to
ob -- object which we want to assign roles to
portal_type -- portal type of object
NOTE: for now, this script requires proxy manager
......@@ -27,11 +27,11 @@ NOTE: for now, this script requires proxy manager
category_list = []
if object is None:
if ob is None:
return []
for base_category in base_category_list:
membership_list = map(lambda x: '%s*' % x, object.getAcquiredCategoryMembershipList(base_category))
membership_list = ['%s*' % x for x in ob.getAcquiredCategoryMembershipList(base_category)]
category_list.append({base_category: membership_list})
return category_list
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>base_category_list, user_name, object, portal_type</string> </value>
<value> <string>base_category_list, user_name, ob, portal_type</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -14,7 +14,7 @@ The parameters are
base_category_list -- list of category values we need to retrieve
user_name -- string obtained from getSecurityManager().getUser().getId()
object -- object which we want to assign roles to
ob -- object which we want to assign roles to
portal_type -- portal type of object
NOTE: for now, this script requires proxy manager
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>base_category_list, user_name, object, portal_type</string> </value>
<value> <string>base_category_list, user_name, ob, portal_type</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -19,7 +19,7 @@ The parameters are
base_category_list -- list of category values we need to retrieve
user_name -- string obtained from getSecurityManager().getUser().getId()
object -- object which we want to assign roles to
ob -- object which we want to assign roles to
portal_type -- portal type of object
NOTE: for now, this script requires proxy manager
......@@ -27,13 +27,13 @@ NOTE: for now, this script requires proxy manager
category_list = []
if object is None:
if ob is None:
return []
# Consider all parents of all categories
for base_category in base_category_list:
member_list = []
for category in object.getAcquiredValueList(base_category):
for category in ob.getAcquiredValueList(base_category):
if category.getPortalType() == 'Category':
while category.getPortalType() == 'Category':
member_list.append(category.getRelativeUrl())
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>base_category_list, user_name, object, portal_type</string> </value>
<value> <string>base_category_list, user_name, ob, portal_type</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
portal = context.getPortalObject()
Base_translateString = portal.Base_translateString
selected_uids = context.portal_selections.updateSelectionCheckedUidList(selection_name,listbox_uid,uids)
context.portal_selections.updateSelectionCheckedUidList(selection_name, listbox_uid,uids)
uids = context.portal_selections.getSelectionCheckedUidsFor(selection_name)
# make sure nothing is checked after
context.portal_selections.setSelectionCheckedUidsFor(selection_name, [])
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>form_id, uids=[], listbox_uid=[], selection_name=\'\'</string> </value>
<value> <string>form_id, uids=(), listbox_uid=(), selection_name=\'\'</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
portal = context.getPortalObject()
Base_translateString = portal.Base_translateString
def Object_hasRelation(object):
# Check if there is some related objets.
result = 0
for o in object.getIndexableChildValueList():
for related in object.portal_categories.getRelatedValueList(object):
if related.getRelativeUrl().startswith(object.getRelativeUrl()):
continue
elif related.getRelativeUrl().startswith('portal_simulation') :
continue
else:
result = 1
break
return result
selected_uids = context.portal_selections.updateSelectionCheckedUidList(selection_name,listbox_uid,uids)
context.portal_selections.updateSelectionCheckedUidList(selection_name,listbox_uid,uids)
uids = context.portal_selections.getSelectionCheckedUidsFor(selection_name)
# make sure nothing is checked after
context.portal_selections.setSelectionCheckedUidsFor(selection_name, [])
......@@ -28,7 +14,7 @@ if uids != []:
object_used = 0
object_list = [x.getObject() for x in context.portal_catalog(uid=uids)]
object_used = sum([Object_hasRelation(x) for x in object_list])
object_used = sum([x.getRelationCountForDeletion() for x in object_list])
if object_used > 0:
if object_used == 1:
......@@ -36,7 +22,6 @@ if uids != []:
else:
message = Base_translateString("Sorry, ${count} items are in use.",
mapping={'count': repr(object_used)})
qs = '?portal_status_message=%s' % message
else:
context.manage_cutObjects(uids=uids, REQUEST=request)
message = Base_translateString("Items cut.")
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>form_id, selection_name=\'\', uids=[], listbox_uid=[]</string> </value>
<value> <string>form_id, selection_name=\'\', uids=(), listbox_uid=()</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -53,18 +53,18 @@ if True:
object_to_remove_list = []
object_to_delete_list = []
for object in object_list:
for obj in object_list:
history_dict = object.Base_getWorkflowHistory()
history_dict = obj.Base_getWorkflowHistory()
history_dict.pop('edit_workflow', None)
if history_dict == {} or object.aq_parent.portal_type=='Preference':
if history_dict == {} or obj.aq_parent.portal_type=='Preference':
# templates inside preference will be unconditionnaly physically
# deleted
object_to_remove_list.append(object)
object_to_remove_list.append(obj)
else:
# If a workflow manage a history,
# object should not be removed, but only put in state deleted
object_to_delete_list.append(object)
object_to_delete_list.append(obj)
# Remove some objects
try:
......@@ -100,16 +100,15 @@ if True:
# Try to call "delete_action" workflow transition on documents which defined it
# Failure of such a call is not a failure globally. The document was deleted anyway
not_deleted_count = 0
for object in object_to_delete_list:
for obj in object_to_delete_list:
# Hidden transition (without a message displayed)
# are not returned by getActionsFor
try:
portal.portal_workflow.doActionFor(object, 'delete_action')
portal.portal_workflow.doActionFor(obj, 'delete_action')
except ConflictError:
raise
except:
not_deleted_count += 1
except Exception:
pass
# make sure nothing is checked after
if selection_name:
......
......@@ -2,8 +2,8 @@ request=context.REQUEST
portal = context.getPortalObject()
Base_translateString = portal.Base_translateString
selected_uids = context.portal_selections.updateSelectionCheckedUidList(selection_name,listbox_uid,uids)
uids = context.portal_selections.getSelectionCheckedUidsFor(selection_name)
portal.portal_selections.updateSelectionCheckedUidList(selection_name,listbox_uid,uids)
uids = portal.portal_selections.getSelectionCheckedUidsFor(selection_name)
if uids == []:
message = Base_translateString("Please select one or more items to delete first.")
......@@ -27,5 +27,5 @@ request.set('proxy_field_id', field_id)
request.set('proxy_field_selection_name', field_selection_name)
request.set('ignore_hide_rows', 1)
context.portal_selections.setSelectionParamsFor('folder_delete_selection', kw)
portal.portal_selections.setSelectionParamsFor('folder_delete_selection', kw)
return context.Folder_viewDeleteDialog(uids=uids, REQUEST=request)
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>selection_index=None,form_id=\'\',uids=[], listbox_uid=[],selection_name=\'\'</string> </value>
<value> <string>selection_index=None, form_id=\'\', uids=(), listbox_uid=(), selection_name=\'\'</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
request = context.REQUEST
stool = context.portal_selections
request = container.REQUEST
selection_tool = context.portal_selections
if stool.getSelectionInvertModeFor(selection_name):
if selection_tool.getSelectionInvertModeFor(selection_name):
# if already in invert mode, toggle invert mode
stool.setSelectionInvertModeFor(selection_name, invert_mode=0)
selection_tool.setSelectionInvertModeFor(selection_name, invert_mode=0)
else:
# Set selection to currently checked items, taking into consideration changes
# in uids
selection_uids = stool.getSelectionCheckedUidsFor(
selection_uids = selection_tool.getSelectionCheckedUidsFor(
selection_name, REQUEST=request)
filtered_uid_dict = {}
listbox_uid = map(lambda x:int(x), listbox_uid)
uids = map (lambda x:int(x), uids)
listbox_uid = [int(x) for x in listbox_uid]
uids = [int(x) for x in uids]
for uid in uids:
filtered_uid_dict[uid] = 1
for uid in selection_uids:
......@@ -22,10 +22,10 @@ else:
filtered_uid_dict[uid] = 1
if len(filtered_uid_dict.keys()) > 0 :
stool.checkAll(selection_name, uids, REQUEST=None)
stool.setSelectionToIds(selection_name,
selection_tool.checkAll(selection_name, uids, REQUEST=None)
selection_tool.setSelectionToIds(selection_name,
filtered_uid_dict.keys(), REQUEST=request)
url = stool.getSelectionListUrlFor(
url = selection_tool.getSelectionListUrlFor(
selection_name, REQUEST=request)
request.RESPONSE.redirect(url)
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>selection_name, uids=[], listbox_uid=[]</string> </value>
<value> <string>selection_name, uids=(), listbox_uid=()</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
from Products.ERP5Form.Report import ReportSection
from Products.ERP5Type.Message import Message
form = context
request = context.REQUEST
report_section_list = []
portal = context.getPortalObject()
......
......@@ -9,9 +9,7 @@ if context.getPortalType() == 'Preference':
result.append(i)
return result
else:
return list(
filter(lambda x: x.getRelationCountForDeletion() == 0, # only docs WITHOUT relations can be deleted
map(lambda x: x.getObject(),
context.portal_catalog(uid=uid, **kw)) # kw can contain limit, sort_on and similar runtime information
)
)
# kw can contain limit, sort_on and similar runtime information
object_list = [x.getObject() for x in context.portal_catalog(uid=uid or -1, **kw)]
# only docs WITHOUT relations can be deleted
return [x for x in object_list if x.getRelationCountForDeletion() == 0]
......@@ -6,7 +6,6 @@ This script is intended as a dialog target.
:param listbox_uid: {list[int]} marks that this script takes objects from previous listbox as its input
:param mass_workflow_action: {str} the ID of (worflow) action to execute on each object
"""
MARKER = []
portal = context.getPortalObject()
request = kwargs.get("REQUEST", None) or context.REQUEST
......
......@@ -9,7 +9,7 @@ if context.cb_dataValid:
else:
if portal_type_set.issubset(context.getVisibleAllowedContentTypeList()):
try:
new_item_list = context.manage_pasteObjects(portal.REQUEST['__cp'])
context.manage_pasteObjects(portal.REQUEST['__cp'])
except KeyError:
error_message = 'Nothing to paste.'
else:
......
......@@ -2,11 +2,6 @@ request = container.REQUEST
from Products.ZSQLCatalog.SQLCatalog import Query, NegatedQuery, ComplexQuery
def sorted(seq):
seq = [x for x in seq]
seq.sort()
return seq
# Convert mapping from request.form into something the catalog can understand
# This script uses ad-hoc values that are understood by
# Folder_viewSearchDialog: x_value_ and x_usage_ are used to remember what was
......
"""
XXX temporary function to recover statistics when needed
=> will be put in an external script.
recover a list with temporary objects we want to apply stats on.
(can be object itself, list of direct sons, list of all sons using
recursive method, etc.)
Then take this special list of objects and return a list of special
temp_objects to display as blocks 'as they are'
"""
from Products.ERP5Type.Log import log
from Products.ERP5Type.Document import newTempMovement as newTempBase
from string import zfill
# first recovering methods to apply on tasks
start_property_id = field.get_value('x_start_bloc')
stop_property_id= field.get_value('x_stop_bloc')
size_property_id = field.get_value('y_size_block')
###########################################################
########### CREATING LIST OF TEMP STAT OBJECTS ############
###########################################################
# find a way to get all related objects with their sub-objects
# this list of objects must be stored in a list
# for now considering applying statistics on object_list
# XXX bug : can not apply getExceptionUidList() method on object_tree_line.
# <<unauthorized access>>
#selection.edit(exception_uid_list= object_tree_line.getExceptionUidList())
input_object_list = selection(method = list_method,context= selection_context,
REQUEST=REQUEST)
temp_object_list = []
temp_object_id = 0
# now applying statictic rule.
# for now statistic rules are static
for input_object in input_object_list:
# recovering input_object attributes
block_begin = input_object.getObject().getProperty(start_property_id,None)
block_end = input_object.getObject().getProperty(stop_property_id,None)
block_size = input_object.getObject().getProperty(size_property_id,None)
if block_begin != None and block_end != None:
# do not create stat on non completed objects.
# prevent bug while size property is not defined on the object
if block_size == None: block_size = block_end - block_begin
#updating block_size value
block_size = float(block_size) / (block_end - block_begin)
# creating new object
temp_object = newTempBase(context.getPortalObject(),id=str(temp_object_id), uid ='new_%s' % zfill(temp_object_id, 4) )
# editing object with new values
log("%s" % (",".join([start_property_id, str(block_begin),stop_property_id, str(block_end),size_property_id, str(block_size)])))
temp_object.setProperty(start_property_id, block_begin)
temp_object.setProperty(stop_property_id, block_end)
temp_object.setProperty(size_property_id, block_size)
# adding new object to list
temp_object_list.append(temp_object)
temp_object_id += 1
###########################################################
################ BUILDING STATS ACTIVITES #################
###########################################################
# building a special list structure.
prop_list = []
for temp_stat in temp_object_list:
block_begin = temp_stat.getProperty(start_property_id)
block_end = temp_stat.getProperty(stop_property_id)
block_size = temp_stat.getProperty(size_property_id)
prop_list.append([block_begin, float(block_size)])
prop_list.append([block_end ,-(float(block_size))])
# now sorting list to put start & stop in the right order
prop_list.sort()
# now building new list of temp object with updated properties
size = 0
temp_stat_object_list = []
for index in range(len(prop_list) - 1):
# iterating all prop_list elements except the last one
current_prop = prop_list[index]
size += current_prop[1] # new size is relative to the previous size
start = current_prop[0] # current start
stop = prop_list[index+1][0] # current stop is the begining of the next block
temp_stat_object_id = 0
if size > 0:
# size is not null
# building new tempObject
temp_stat_object_id += 1
temp_stat_object = newTempBase(context.getPortalObject(),str(temp_stat_object_id), uid ='new_%s' % zfill(temp_stat_object_id, 4))
# editing object with new values
temp_stat_object.setProperty(start_property_id, start)
temp_stat_object.setProperty(stop_property_id, stop)
temp_stat_object.setProperty(size_property_id, size)
# adding new object to list
temp_stat_object_list.append(temp_stat_object)
temp_stat_object_id +=1
return temp_stat_object_list
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>selection=None,list_method=None, selection_context=None, report_tree_list = None, object_tree_line=None, REQUEST=None, field=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Planning_commonStats</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -5,7 +5,7 @@
# - Implement validation of matrix fields
# - Implement validation of list fields
#
from Products.Formulator.Errors import ValidationError, FormValidationError
from Products.Formulator.Errors import FormValidationError
from ZTUtils import make_query
request=context.REQUEST
......@@ -34,12 +34,12 @@ try:
listbox_field = form.get_field('listbox')
gv = {}
if listbox_field.has_value('global_attributes'):
hidden_attributes = map(lambda x:x[0], listbox_field.get_value('global_attributes'))
hidden_attributes = [x[0] for x in listbox_field.get_value('global_attributes')]
for k in hidden_attributes:
gv[k] = getattr(request, k,None)
for property, v in listbox.items():
for property_, v in listbox.items():
v.update(gv)
context.setCriterion(property, **v)
context.setCriterion(property_, **v)
# Update basic attributes
context.edit(REQUEST=request, edit_order=edit_order, **kw)
context.reindexObject()
......
"""
This script is used in parallel list fields in Predicate_view
"""
if default_sub_field_property_dict is None:
default_sub_field_property_dict = {}
# Initialise result
sub_field_list = []
......@@ -28,6 +30,4 @@ for category in category_list:
z += 1
sub_field_list.append(new_dict)
request = context.REQUEST
return sub_field_list
......@@ -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>
......
portal = context.getPortalObject()
N_ = portal.Base_translateString
request = container.REQUEST
style = request.get('your_portal_skin',
......
......@@ -7,7 +7,6 @@ from Products.ERP5Type.Document import newTempBase
# get all cache statistics
cache_stats = context.getPortalObject().portal_caches.getCacheTotalMemorySize()
cache_factory_list_stats = cache_stats['stats']
cache_plugin_id = context.getId()
cache_factory_id = context.getParentValue().getId()
cache_plugin_stats = cache_factory_list_stats.get(
cache_factory_id,
......
if default_sub_field_property_dict is None:
default_sub_field_property_dict = {}
# Remove empty items
item_list = filter(lambda x: x not in [('',''), ['','']],
item_list)
item_list = [x for x in item_list if x not in (('',''), ['',''])]
sub_field_dict = {}
split_depth = 1
......
......@@ -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>
......
......@@ -12,8 +12,8 @@ if len(uids) == 0:
id_list = []
for uid in uids:
repository, id = context.decodeRepositoryBusinessTemplateUid(uid)
bt = context.download('/'.join([repository, id]))
repository, id_ = context.decodeRepositoryBusinessTemplateUid(uid)
bt = context.download('/'.join([repository, id_]))
id_list.append(bt.getId())
RESPONSE.redirect("%s?portal_status_message=Business+Templates+Downloaded+As:+%s" % (ret_url, ',+'.join(id_list)))
......@@ -3,7 +3,6 @@ update_catalog = update_translation = 0
bt_id_list = getattr(context.REQUEST, 'bt_list', ())
bt_dict = {}
object_to_update = {}
for item in listbox:
# backward compatibility
if not same_type(item['choice'], []):
......
......@@ -73,8 +73,8 @@ tuple_list = context.sortBusinessTemplateList(tuple_list)
bt_list = []
for repository, id in tuple_list:
bt = context.download('/'.join([repository, id]))
for repository, id_ in tuple_list:
bt = context.download('/'.join([repository, id_]))
bt_list.append(bt.getId())
RESPONSE.redirect(
......
......@@ -12,7 +12,6 @@ from zExceptions import Unauthorized
portal = context.getPortalObject()
portal_diff = portal.portal_diff
request = context.REQUEST
object_revision_list = []
history_size = portal.portal_preferences.getPreferredHtmlStyleZodbHistorySize()
first_object = None
......@@ -105,7 +104,7 @@ if ((first_path is None and second_path is None) and
first_object = selected_object_list[0]
second_object = selected_object_list[1]
# Use DiffTool to get the diff between the 2 objects in object_revision_list List.
# Use DiffTool to get the diff between the 2 objects.
# These 2 objects can be revisions of same object, 2 different revisions of
# different objects or 2 current ERP5 object.
if first_object and second_object:
......
object = state_change['object']
object.Base_checkConsistency()
state_change['object'].Base_checkConsistency()
......@@ -849,7 +849,7 @@ class PlanningBoxWidget(Widget.Widget):
round_script = fields.StringField('round_script',
title='Name of script rounding blocks during validation (ex. ' \
'Planning_roundBoundToDay)',
'Base_roundPlanningBoxBoundToDay)',
description='script for block bounds rounding when validating',
default='',
required=0)
......
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