Commit 31e71335 authored by Jérome Perrin's avatar Jérome Perrin

core: fixes for pylint

The general approach is:
- replace deprecated lambdas with list comprehensions
- remove unused variables/imports
- replace dangerous arguments [] with ()
- replace dangerous arguments {} with None and "if None -> {}"
- replace builtin names with something similar

Now that all problems reported by pylint are fixed, enable coding style
test.
parent 04489999
...@@ -37,7 +37,7 @@ class ScriptConstraint(ConstraintMixin): ...@@ -37,7 +37,7 @@ class ScriptConstraint(ConstraintMixin):
portal_type = 'Script Constraint' portal_type = 'Script Constraint'
def _createConsistencyMessage(self, object_relative_url, message, mapping): 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 from Products.ERP5Type.ConsistencyMessage import ConsistencyMessage
return ConsistencyMessage(self, return ConsistencyMessage(self,
object_relative_url=object_relative_url, object_relative_url=object_relative_url,
......
...@@ -107,23 +107,8 @@ def getExcerptText(context, txt, sw, tags, trail, maxlines): ...@@ -107,23 +107,8 @@ def getExcerptText(context, txt, sw, tags, trail, maxlines):
txt = txt.replace('-',' - ') # to find hyphenated occurrences txt = txt.replace('-',' - ') # to find hyphenated occurrences
txt = txt.replace(',',', ') txt = txt.replace(',',', ')
txt = txt.replace(';','; ') txt = txt.replace(';','; ')
r = re.compile('\s+') r = re.compile(r'\s+')
txt = re.sub(r,' ',txt) txt = re.sub(r,' ',txt)
text = ' '.join(txt.split('\n')).split(' ') # very rough tokenization text = ' '.join(txt.split('\n')).split(' ') # very rough tokenization
return [p for p in generateParts(context,text,sw,tags,trail,maxlines)] 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): ...@@ -52,7 +52,6 @@ def getDocumentGroupByWorkflowStateList(self, form_id='', **kw):
doc.getPortalTypeName()) doc.getPortalTypeName())
return get_url return get_url
request = self.REQUEST
portal = self.getPortalObject() portal = self.getPortalObject()
Base_translateString = portal.Base_translateString Base_translateString = portal.Base_translateString
wf_tool = portal.portal_workflow wf_tool = portal.portal_workflow
......
...@@ -45,9 +45,7 @@ ...@@ -45,9 +45,7 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple/>
<string>W: 55, 2: Unused variable \'request\' (unused-variable)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
from Products.ZSQLCatalog.zsqlbrain import ZSQLBrain from Products.ZSQLCatalog.zsqlbrain import ZSQLBrain
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
from ZTUtils import make_query from ZTUtils import make_query
from Products.CMFCore.utils import getToolByName
from Products.ERP5Type.Message import translateString from Products.ERP5Type.Message import translateString
from ComputedAttribute import ComputedAttribute from ComputedAttribute import ComputedAttribute
......
...@@ -45,9 +45,7 @@ ...@@ -45,9 +45,7 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple/>
<string>W: 17, 0: Unused getToolByName imported from Products.CMFCore.utils (unused-import)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
......
from AccessControl import getSecurityManager
from zExceptions import Unauthorized from zExceptions import Unauthorized
if REQUEST is not None: # Cheap "do not call from URL" protection - not that the session key is secret if REQUEST is not None: # Cheap "do not call from URL" protection - not that the session key is secret
raise Unauthorized raise Unauthorized
......
from ZTUtils import make_query from ZTUtils import make_query
object = brain.getObject() obj = brain.getObject()
if object is None: if obj is None:
return None return None
url = context.absolute_url() url = context.absolute_url()
method = context.getReportMethodId('Alarm_viewReport') method = context.getReportMethodId('Alarm_viewReport')
kw = { 'active_process' : 'portal_activities/%s' % object.id, kw = { 'active_process' : 'portal_activities/%s' % obj.id,
'reset' : '1', 'reset' : '1',
} }
......
...@@ -104,7 +104,6 @@ except FormValidationError, validation_errors: ...@@ -104,7 +104,6 @@ except FormValidationError, validation_errors:
can_redirect = 1 can_redirect = 1
MARKER = [] # A recognisable default value. Use with 'is', not '=='. 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. 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(): for field in form.get_fields():
k = field.id k = field.id
v = request.get(k, MARKER) v = request.get(k, MARKER)
...@@ -151,7 +150,7 @@ if len(listbox_id_list): ...@@ -151,7 +150,7 @@ if len(listbox_id_list):
if hasattr(kw, 'previous_md5_object_uid_list'): if hasattr(kw, 'previous_md5_object_uid_list'):
selection_list = context.portal_selections.callSelectionFor(kw['list_selection_name'], context=context) selection_list = context.portal_selections.callSelectionFor(kw['list_selection_name'], context=context)
if selection_list is not None: 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) error = context.portal_selections.selectionHasChanged(kw['previous_md5_object_uid_list'], object_uid_list)
if error: if error:
error_message = context.Base_translateString("Sorry, your selection has changed.") error_message = context.Base_translateString("Sorry, your selection has changed.")
...@@ -167,7 +166,7 @@ listbox_uid = kw.get('listbox_uid', None) ...@@ -167,7 +166,7 @@ listbox_uid = kw.get('listbox_uid', None)
# In such cases, we must not try to update a non-existing selection. # 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'): if listbox_uid is not None and kw.has_key('list_selection_name'):
uids = kw.get('uids') uids = kw.get('uids')
selected_uids = context.portal_selections.updateSelectionCheckedUidList( context.portal_selections.updateSelectionCheckedUidList(
kw['list_selection_name'], kw['list_selection_name'],
listbox_uid, uids) listbox_uid, uids)
# Remove values which doesn't work with make_query. # Remove values which doesn't work with make_query.
......
# Updates attributes of an Zope document from Products.Formulator.Errors import FormValidationError
# which is in a class inheriting from ERP5 Base
from Products.Formulator.Errors import ValidationError, FormValidationError
request = context.REQUEST request = context.REQUEST
field_sort_type = request.form.get('field_sort_type', None) field_sort_type = request.form.get('field_sort_type', None)
......
# Updates attributes of an Zope document from Products.Formulator.Errors import FormValidationError
# which is in a class inheriting from ERP5 Base
from Products.Formulator.Errors import ValidationError, FormValidationError
request=context.REQUEST request=context.REQUEST
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
this type cannot be added in the container. this type cannot be added in the container.
""" """
Base_translateString = context.Base_translateString Base_translateString = context.Base_translateString
REQUEST=context.REQUEST
parent = context.getParentValue() parent = context.getParentValue()
allowed_type_list = parent.getVisibleAllowedContentTypeList() allowed_type_list = parent.getVisibleAllowedContentTypeList()
......
...@@ -19,11 +19,11 @@ for v in values: ...@@ -19,11 +19,11 @@ for v in values:
# We should not edit the id field # We should not edit the id field
# because the object which is created is not attached to a # because the object which is created is not attached to a
# module yet # module yet
id = v id_ = v
else: else:
id=str(module.generateNewId()) id_ = str(module.generateNewId())
module.invokeFactory(type_name=portal_type,id=id) module.invokeFactory(type_name=portal_type, id=id_)
new_ob = module.get(id) new_ob = module.get(id_)
kw = {} kw = {}
if catalog_index != 'id': if catalog_index != 'id':
kw[catalog_index] = v kw[catalog_index] = v
...@@ -34,59 +34,3 @@ for v in values: ...@@ -34,59 +34,3 @@ for v in values:
o.setValue(base_category, ref_list, portal_type=[portal_type]) o.setValue(base_category, ref_list, portal_type=[portal_type])
return request[ 'RESPONSE' ].redirect( return_url ) 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): ...@@ -57,7 +57,7 @@ def editListBox(listbox_field, listbox):
if listbox is not None: if listbox is not None:
global_property_dict = {} global_property_dict = {}
if listbox_field.has_value('global_attributes'): 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: for hidden_attribute in hidden_attribute_list:
global_property_dict[hidden_attribute] = getattr(request, hidden_attribute, None) global_property_dict[hidden_attribute] = getattr(request, hidden_attribute, None)
for item_url, listbox_item_dict in listbox.items(): for item_url, listbox_item_dict in listbox.items():
...@@ -129,10 +129,10 @@ def editMatrixBox(matrixbox_field, matrixbox): ...@@ -129,10 +129,10 @@ def editMatrixBox(matrixbox_field, matrixbox):
columns = matrixbox_field.get_value('columns') columns = matrixbox_field.get_value('columns')
tabs = matrixbox_field.get_value('tabs') tabs = matrixbox_field.get_value('tabs')
column_ids = map(lambda x: x[0], columns) column_ids = [x[0] for x in columns]
line_ids = map(lambda x: x[0], lines) line_ids = [x[0] for x in lines]
tab_ids = map(lambda x: x[0], tabs) tab_ids = [x[0] for x in tabs]
extra_dimension_category_list_list = [[category for category, label in dimension_list] for dimension_list in extra_dimension_list_list] extra_dimension_category_list_list = [[category for category, _ in dimension_list] for dimension_list in extra_dimension_list_list]
# There are 3 cases # There are 3 cases
# Case 1: we do 1 dimensional matrix # Case 1: we do 1 dimensional matrix
...@@ -250,8 +250,6 @@ server_physical_path = context.getPhysicalPath() ...@@ -250,8 +250,6 @@ server_physical_path = context.getPhysicalPath()
server_physical_path = list(server_physical_path) server_physical_path = list(server_physical_path)
server_url = request["SERVER_URL"] server_url = request["SERVER_URL"]
server_physical_path.insert(0, 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 # for web mode, we should use 'view' instead of passed form_id
# after 'Save & View'. # after 'Save & View'.
......
# Updates relation of an ERP5 document # 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 from Products.ERP5Form.MultiRelationField import SUB_FIELD_ID
if listbox_uid is not None: if listbox_uid is not None:
selection_tool = context.getPortalObject().portal_selections selection_tool = context.getPortalObject().portal_selections
selected_uids = selection_tool.updateSelectionCheckedUidList( selection_tool.updateSelectionCheckedUidList(
selection_name, listbox_uid, uids) selection_name, listbox_uid, uids)
uids = selection_tool.getSelectionCheckedUidsFor(selection_name) uids = selection_tool.getSelectionCheckedUidsFor(selection_name)
......
from Products.ERP5Type.Document import newTempDomain
domain_list=[] domain_list=[]
request = context.REQUEST request = context.REQUEST
filter = {} filter_ = {}
try: try:
# first, try to get form_id from the request # first, try to get form_id from the request
...@@ -12,7 +11,7 @@ except KeyError: ...@@ -12,7 +11,7 @@ except KeyError:
if listbox is not None: if listbox is not None:
portal_type_list = [x[0] for x in listbox.get_value('portal_types')] 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: if depth == 0:
parent_obj = request['here'] parent_obj = request['here']
...@@ -22,7 +21,7 @@ else: ...@@ -22,7 +21,7 @@ else:
parent_url = parent.getProperty('parent_url') parent_url = parent.getProperty('parent_url')
parent_obj = context.restrictedTraverse(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 = parent.generateTempDomain(id='%s_%s' % (depth, obj.getId()))
domain.edit(title=obj.getTitle(), domain.edit(title=obj.getTitle(),
parent_url=obj.getRelativeUrl(), parent_url=obj.getRelativeUrl(),
......
...@@ -10,4 +10,4 @@ if include_letters: ...@@ -10,4 +10,4 @@ if include_letters:
character_set = '%s%s' %(character_set, letters) character_set = '%s%s' %(character_set, letters)
if include_digits: if include_digits:
character_set = '%s%s' %(character_set, 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) ...@@ -21,12 +21,6 @@ current_date = DateTime(year, 1, 1)
default_link_url ='setLanePath?form_id=%s&list_selection_name=%s' %( default_link_url ='setLanePath?form_id=%s&list_selection_name=%s' %(
form_id, selection_name) 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 = [] category_list = []
if depth == 0: if depth == 0:
# getting list of months # getting list of months
......
...@@ -88,13 +88,12 @@ if not (content_type.startswith('application/vnd.sun.xml') ...@@ -88,13 +88,12 @@ if not (content_type.startswith('application/vnd.sun.xml')
tmp_ooo.edit(data=import_file.read(), tmp_ooo.edit(data=import_file.read(),
content_type=content_type) content_type=content_type)
tmp_ooo.convertToBaseFormat() tmp_ooo.convertToBaseFormat()
ignored, import_file_content = tmp_ooo.convert('ods') _, import_file_content = tmp_ooo.convert('ods')
parser.openFromString(str(import_file_content)) parser.openFromString(str(import_file_content))
else: else:
parser.openFile(import_file) parser.openFile(import_file)
# Extract tables from the speadsheet file # Extract tables from the speadsheet file
filename = parser.getFilename()
spreadsheet_list = parser.getSpreadsheetsMapping(no_empty_lines=True) spreadsheet_list = parser.getSpreadsheetsMapping(no_empty_lines=True)
...@@ -128,8 +127,6 @@ for table_name in spreadsheet_list.keys(): ...@@ -128,8 +127,6 @@ for table_name in spreadsheet_list.keys():
else: else:
# If there is a new column with a header and the path definition has # If there is a new column with a header and the path definition has
# started, that seems the path definition has ended # 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') property_map[column_index] = column_id.encode('utf8')
column_index += 1 column_index += 1
......
if context.REQUEST.has_key('workflow_action'): # We are on a workflow transition 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: 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: elif form_id is not None:
help = '%s_%s' % (context.getPortalTypeName(), form_id) help_relative_url = '%s_%s' % (context.getPortalTypeName(), form_id)
else: else:
help = context.getPortalTypeName() help_relative_url = context.getPortalTypeName()
return '%s/%s' % (context.portal_preferences.getPreferredHtmlStyleDocumentationBaseUrl(), help) 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. # Define a dictionary where we store the subfields to display.
sub_field_dict = {} sub_field_dict = {}
split_depth = 1 split_depth = 1
......
...@@ -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>
......
if default_sub_field_property_dict is None:
default_sub_field_property_dict = {}
# Define a dictionary where we store the subfields to display. # Define a dictionary where we store the subfields to display.
sub_field_dict = {} sub_field_dict = {}
split_depth = 1 split_depth = 1
......
...@@ -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>
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -8,14 +8,14 @@ translation_map = { "a": ['\xe0'] ...@@ -8,14 +8,14 @@ translation_map = { "a": ['\xe0']
} }
clean_id = '' clean_id = ''
if string == None: if s is None:
return None return None
string = string.lower() s = s.lower()
string = string.strip() s = s.strip()
# oocalc inserts some strange chars when you press - key in a text cell. # 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 # Following line is a workaround for this, because \u2013 does not exist in latin1
string = string.replace(u'\u2013', '-') s = s.replace(u'\u2013', '-')
for char in string.encode('iso8859_1'): for char in s.encode('iso8859_1'):
if char == '_' or char.isalnum(): if char == '_' or char.isalnum():
clean_id += char clean_id += char
elif char.isspace() or char in ('+', '-'): elif char.isspace() or char in ('+', '-'):
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>string=None</string> </value> <value> <string>s=None</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
# controls the visibility of "developper mode" links in ERP5 web interface # controls the visibility of "developper mode" links in ERP5 web interface
# (edit form, edit field, edit portal type, ...) for object # (edit form, edit field, edit portal type, ...) for object
if object is None: if obj is None:
object = context 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 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>object=None</string> </value> <value> <string>obj=None</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -5,7 +5,7 @@ history_name_list = ['building_history', ' installation_history', 'history'] ...@@ -5,7 +5,7 @@ history_name_list = ['building_history', ' installation_history', 'history']
history = {} history = {}
portal_workflow = context.getPortalObject().portal_workflow 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: for history_name in history_name_list:
...@@ -16,7 +16,7 @@ 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) list_history_item = portal_workflow.getInfoFor(ob=context, name=history_name, wf_id=wf_id)
except ConflictError: except ConflictError:
raise raise
except: except Exception:
pass pass
if list_history_item not in ((), None): if list_history_item not in ((), None):
......
request = context.REQUEST
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
from Products.ERP5Type.Document import newTempMappedValue
from Products.ERP5Type.Utils import getTranslationStringWithContext from Products.ERP5Type.Utils import getTranslationStringWithContext
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
...@@ -12,7 +10,7 @@ result = [] ...@@ -12,7 +10,7 @@ result = []
i = 1 i = 1
portal_object = context.getPortalObject() portal_object = context.getPortalObject()
portal_workflow = portal_object.portal_workflow 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: if not workflow_id in workflow_id_list:
return [] return []
...@@ -31,12 +29,8 @@ def getActorName(actor): ...@@ -31,12 +29,8 @@ def getActorName(actor):
# Get history # Get history
# XXX Compatibility workflow_item_list = portal_workflow.getInfoFor(
for history_name in ['history', 'building_history', 'installation_history']: ob=context, name='history', wf_id=workflow_id)
workflow_item_list = portal_workflow.getInfoFor(ob=context,
name='history', wf_id=workflow_id)
if workflow_item_list != []:
break
wf_state_var = portal_workflow[workflow_id].variables.getStateVar() wf_state_var = portal_workflow[workflow_id].variables.getStateVar()
wf_states = portal_workflow[workflow_id].states wf_states = portal_workflow[workflow_id].states
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
in such way that it is possible to select multiple in such way that it is possible to select multiple
categories for the same document ) categories for the same document )
""" """
if default_sub_field_property_dict is None:
default_sub_field_property_dict = {}
# Initialise result # Initialise result
sub_field_list = [] sub_field_list = []
......
...@@ -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>
......
from ZTUtils import make_query
request=context.REQUEST request=context.REQUEST
form = getattr(context,form_id) form = getattr(context,form_id)
field = form.get_field(field_id) field = form.get_field(field_id)
base_category = field.get_value('base_category') 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 = {} kw = {}
for k, v in field.get_value('parameter_list') : for k, v in field.get_value('parameter_list') :
kw[k] = v kw[k] = v
...@@ -16,7 +14,7 @@ if len(jump_reference_list)==1: ...@@ -16,7 +14,7 @@ if len(jump_reference_list)==1:
jump_reference = jump_reference_list[0] jump_reference = jump_reference_list[0]
return jump_reference.Base_redirect() return jump_reference.Base_redirect()
else: 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} kw = {'uid': selection_uid_list}
# We need to reset the selection. Indeed, some sort columns done in another # We need to reset the selection. Indeed, some sort columns done in another
# jump could be meaningless for this particular jump. The consequence could # jump could be meaningless for this particular jump. The consequence could
......
...@@ -11,6 +11,6 @@ def generic_sort(a,b): ...@@ -11,6 +11,6 @@ def generic_sort(a,b):
return result return result
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) unordered_list.sort(generic_sort)
return unordered_list return unordered_list
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>unordered_list=[], sort_order=()</string> </value> <value> <string>unordered_list, sort_order=()</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
from string import zfill from string import zfill
request = context.REQUEST request = context.REQUEST
from string import zfill
if kw.get('update', False): if kw.get('update', False):
# Ensure ERP5JS correctly refresh the page # Ensure ERP5JS correctly refresh the page
request.RESPONSE.setStatus(400) request.RESPONSE.setStatus(400)
......
from Products.ERP5Type.Log import log
portal = container.getPortalObject() portal = container.getPortalObject()
if not(id_value.endswith(portal.restrictedTraverse(REQUEST.object_path)\ if not(id_value.endswith(portal.restrictedTraverse(REQUEST.object_path)\
.getIdAsReferenceSuffix())): .getIdAsReferenceSuffix())):
......
from Products.Formulator.Errors import ValidationError, FormValidationError from Products.Formulator.Errors import FormValidationError
from ZTUtils import make_query from ZTUtils import make_query
portal = context.getPortalObject() portal = context.getPortalObject()
Base_translateString = portal.Base_translateString Base_translateString = portal.Base_translateString
...@@ -46,8 +46,6 @@ def getOrderedUids(uids, values, catalog_index): ...@@ -46,8 +46,6 @@ def getOrderedUids(uids, values, catalog_index):
uids.append(value_to_uid[value]) uids.append(value_to_uid[value])
return uids return uids
field.get_value('base_category')
try: try:
# Validate the form # Validate the form
form = getattr(context,form_id) form = getattr(context,form_id)
...@@ -71,7 +69,6 @@ try: ...@@ -71,7 +69,6 @@ try:
new_value = v new_value = v
base_category = f.get_value( 'base_category') base_category = f.get_value( 'base_category')
if my_field and base_category is not None: if my_field and base_category is not None:
empty_list = 0
if new_value == '': if new_value == '':
new_value = [] new_value = []
if same_type(new_value,'a'): if same_type(new_value,'a'):
...@@ -90,7 +87,7 @@ try: ...@@ -90,7 +87,7 @@ try:
if checkSameKeys(new_value, old_value): if checkSameKeys(new_value, old_value):
# Reorder keys # Reorder keys
same_keys = 1 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 # We work with strings - ie. single values
kw ={} kw ={}
kw[my_field.get_value('catalog_index')] = new_value kw[my_field.get_value('catalog_index')] = new_value
...@@ -103,7 +100,7 @@ try: ...@@ -103,7 +100,7 @@ try:
request.set('field_id', my_field.id) request.set('field_id', my_field.id)
previous_uids = o.getValueUidList(base_category, portal_type=portal_type) previous_uids = o.getValueUidList(base_category, portal_type=portal_type)
relation_list = context.portal_catalog(**kw) 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 = [] uids = []
for uid in previous_uids: for uid in previous_uids:
if uid in relation_uid_list: if uid in relation_uid_list:
......
...@@ -13,10 +13,10 @@ from pprint import pformat ...@@ -13,10 +13,10 @@ from pprint import pformat
ret = '<html><body><table width=100%>\n' ret = '<html><body><table width=100%>\n'
dict = context.showDict().items() property_dict = context.showDict().items()
dict.sort() property_dict.sort()
i = 0 i = 0
for k,v in dict: for k,v in property_dict:
if (i % 2) == 0: if (i % 2) == 0:
c = '#88dddd' c = '#88dddd'
else: else:
......
REQUEST=context.REQUEST REQUEST=context.REQUEST
RESPONSE=REQUEST.RESPONSE
return context.portal_templates.save(context, REQUEST=REQUEST) return context.portal_templates.save(context, REQUEST=REQUEST)
...@@ -72,12 +72,10 @@ for base_category, category_list in category_list_spreadsheet_dict.iteritems(): ...@@ -72,12 +72,10 @@ for base_category, category_list in category_list_spreadsheet_dict.iteritems():
except ValueError: except ValueError:
category_id = category_path category_id = category_path
container = portal_categories container = portal_categories
is_base_category = True
category_type = 'Base Category' category_type = 'Base Category'
category_type_property_id_set = base_category_property_id_set category_type_property_id_set = base_category_property_id_set
else: else:
container = resolveCategory(container_path) container = resolveCategory(container_path)
is_base_category = False
category_type = 'Category' category_type = 'Category'
category_type_property_id_set = category_property_id_set category_type_property_id_set = category_property_id_set
try: try:
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -2,7 +2,7 @@ from Products.ERP5Type.Log import log ...@@ -2,7 +2,7 @@ from Products.ERP5Type.Log import log
# this script is no longer needed. # this script is no longer needed.
log('Category_getSortedCategoryChildValueList', 'use getCategoryChildValueList method') 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' sort_id='int_index'
value_list.sort(key=lambda x: x.getProperty(sort_id)) value_list.sort(key=lambda x: x.getProperty(sort_id))
return value_list return value_list
...@@ -42,8 +42,8 @@ if depth == maximum_depth and id_list: ...@@ -42,8 +42,8 @@ if depth == maximum_depth and id_list:
if recursive: if recursive:
for subdocument in document.objectValues(): for subdocument in document.objectValues():
recurse(subdocument) recurse(subdocument)
for id in id_list: for id_ in id_list:
recurse(document[id]) recurse(document[id_])
if active_process is None: if active_process is None:
return error_list return error_list
if error_list: if error_list:
...@@ -84,8 +84,8 @@ else: ...@@ -84,8 +84,8 @@ else:
active_script = getattr(activate(priority=4), script.id) active_script = getattr(activate(priority=4), script.id)
if depth < maximum_depth: if depth < maximum_depth:
relative_url = relative_url and relative_url + '/' or '' relative_url = relative_url and relative_url + '/' or ''
for id in id_list: for id_ in id_list:
active_script(relative_url=relative_url + id, **kw) active_script(relative_url=relative_url + id_, **kw)
else: else:
kw['relative_url'] = relative_url kw['relative_url'] = relative_url
for i in xrange(0, len(id_list), packet): for i in xrange(0, len(id_list), packet):
......
...@@ -85,13 +85,13 @@ def checkField(folder, form, field): ...@@ -85,13 +85,13 @@ def checkField(folder, form, field):
a = template_field.getListMethodName() a = template_field.getListMethodName()
path += '/listbox' path += '/listbox'
for x in 'columns', 'all_columns': 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) error_message += checkTitle(path, x, title, field, form)
if a not in (None, "portal_catalog", "searchFolder", "objectValues", if a not in (None, "portal_catalog", "searchFolder", "objectValues",
"contentValues", "ListBox_initializeFastInput"): "contentValues", "ListBox_initializeFastInput"):
if not a.endswith('List'): if not a.endswith('List'):
if 0: 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 return error_message
def isListBox(field): def isListBox(field):
...@@ -107,7 +107,7 @@ titlecase_sub = re.compile(r"[A-Za-z]+('[A-Za-z]+)?").sub ...@@ -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_repl = lambda mo: mo.group(0)[0].upper() + mo.group(0)[1:].lower()
titlecase = lambda s: titlecase_sub(titlecase_repl, s) 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. Generic function that test the validity of a title.
""" """
...@@ -115,11 +115,11 @@ def checkTitle(path, id, title, field=None, form=None): ...@@ -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 (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 \ 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)): (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: for c in title:
if c.lower() not in ALLOWED_CHARS: 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) 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): ...@@ -132,22 +132,22 @@ def checkTitle(path, id, title, field=None, form=None):
if word.upper() in ABBREVIATION_WORD_SET: if word.upper() in ABBREVIATION_WORD_SET:
if not word.isupper(): 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: elif word.endswith('s') and word[:-1].upper() in ABBREVIATION_WORD_SET:
if not word[:-1].isupper(): 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: elif "-" in word and word.split("-")[0].upper() in ABBREVIATION_WORD_SET:
if not word.split("-")[0].isupper(): 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: else:
if word.lower() in CLOSED_CLASS_WORD_SET and word != word_list[0] : if word.lower() in CLOSED_CLASS_WORD_SET and word != word_list[0] :
if (word.capitalize()== word or titlecase(word)== word): 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 \ 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 : 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': 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 return error_message
......
help = context.getPortalTypeName() help_topic = context.getPortalTypeName()
if workflow_action is not None: # First, the workflow transition case. 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. 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. elif current_form_id is not None: # Otherwise, get the form we are in.
help = '%s_%s' % (help, current_form_id) help_topic = '%s_%s' % (help_topic, current_form_id)
return '%s/%s' % (context.portal_preferences.getPreferredHtmlStyleDocumentationBaseUrl(), help) return '%s/%s' % (context.portal_preferences.getPreferredHtmlStyleDocumentationBaseUrl(), help_topic)
...@@ -4,7 +4,6 @@ Content will be created in the appropriate module. It is ...@@ -4,7 +4,6 @@ Content will be created in the appropriate module. It is
intended to be called from the user interface only. intended to be called from the user interface only.
""" """
translateString = context.Base_translateString translateString = context.Base_translateString
request = context.REQUEST
# Create the new content in appropriate module # Create the new content in appropriate module
portal_object = context.getPortalObject() portal_object = context.getPortalObject()
......
...@@ -10,23 +10,23 @@ nb_types = {} ...@@ -10,23 +10,23 @@ nb_types = {}
for error in error_list: for error in error_list:
# We count the number of each portal type # We count the number of each portal type
if error[1]=='portal_type': if error[1]=='portal_type':
type = error[3] portal_type = error[3]
if nb_types.has_key(type): if nb_types.has_key(portal_type):
nb_types[type] = nb_types[type] + 1 nb_types[portal_type] = nb_types[portal_type] + 1
else: else:
nb_types[type] = 1 nb_types[portal_type] = 1
else: else:
#print error #print error
return_list.append(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 # 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] 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" % \ 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)) 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 return return_list
...@@ -13,7 +13,7 @@ unindex_count = 0 ...@@ -13,7 +13,7 @@ unindex_count = 0
for candidate in candidate_list: for candidate in candidate_list:
path = candidate['path'] path = candidate['path']
try: try:
object = portal.restrictedTraverse(path) obj = portal.restrictedTraverse(path)
except KeyError: except KeyError:
# Object is unreachable, remove it from catalog # Object is unreachable, remove it from catalog
# Use SQLQueue because all activities are triggered on the same object, # Use SQLQueue because all activities are triggered on the same object,
...@@ -21,7 +21,7 @@ for candidate in candidate_list: ...@@ -21,7 +21,7 @@ for candidate in candidate_list:
catalog.activate(activity="SQLQueue").unindexObject(uid=candidate['uid']) catalog.activate(activity="SQLQueue").unindexObject(uid=candidate['uid'])
unindex_count += 1 unindex_count += 1
else: else:
object.reindexObject() obj.reindexObject()
reindex_count += 1 reindex_count += 1
print '%s object reindexed, %s object unindexed' % (reindex_count, unindex_count) print '%s object reindexed, %s object unindexed' % (reindex_count, unindex_count)
......
activate_kw = {"tag" : tag} activate_kw = {"tag" : tag}
folder = context.restrictedTraverse(folder_path) folder = context.restrictedTraverse(folder_path)
method = getattr(context, method) method = getattr(context, method)
for id in id_list: for id_ in id_list:
ob = folder.get(id) ob = folder.get(id_)
new_id = method(ob) new_id = method(ob)
ob.setDefaultActivateParameterDict(activate_kw) ob.setDefaultActivateParameterDict(activate_kw)
ob.setId(new_id) ob.setId(new_id)
...@@ -11,9 +11,9 @@ z_catalog_translation_list = sql_catalog.z_catalog_translation_list ...@@ -11,9 +11,9 @@ z_catalog_translation_list = sql_catalog.z_catalog_translation_list
def catalog_translation_list(object_list): def catalog_translation_list(object_list):
parameter_dict = {} parameter_dict = {}
for i in object_list: 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'): 'original_message', 'translated_message'):
parameter_dict.setdefault(property, []).append(i[property]) parameter_dict.setdefault(property_, []).append(i[property_])
z_catalog_translation_list(**parameter_dict) z_catalog_translation_list(**parameter_dict)
# Translate every workflow state in the context of the state variable # Translate every workflow state in the context of the state variable
......
...@@ -10,10 +10,10 @@ If unsure, you should use ERP5Type_getSecurityCategoryFromContent. ...@@ -10,10 +10,10 @@ If unsure, you should use ERP5Type_getSecurityCategoryFromContent.
""" """
category_list = [] category_list = []
if object is None: if ob is None:
return [] return []
for base_category in base_category_list: 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 return category_list
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</string> </key>
......
...@@ -3,4 +3,4 @@ log("ERP5Type_getSecurityCategoryFromArrow is deprecated, " ...@@ -3,4 +3,4 @@ log("ERP5Type_getSecurityCategoryFromArrow is deprecated, "
"use ERP5Type_getSecurityCategoryFromContent instead") "use ERP5Type_getSecurityCategoryFromContent instead")
return context.ERP5Type_getSecurityCategoryFromContent( return context.ERP5Type_getSecurityCategoryFromContent(
base_category_list, user_name, object, portal_type) base_category_list, user_name, ob, portal_type)
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</string> </key>
......
...@@ -19,7 +19,7 @@ The parameters are ...@@ -19,7 +19,7 @@ The parameters are
base_category_list -- list of category values we need to retrieve base_category_list -- list of category values we need to retrieve
user_name -- string obtained from getSecurityManager().getUser().getId() 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 portal_type -- portal type of object
NOTE: for now, this script requires proxy manager NOTE: for now, this script requires proxy manager
...@@ -27,10 +27,10 @@ NOTE: for now, this script requires proxy manager ...@@ -27,10 +27,10 @@ NOTE: for now, this script requires proxy manager
category_list = [] category_list = []
if object is None: if ob is None:
return [] return []
for base_category in base_category_list: 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 return category_list
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</string> </key>
......
...@@ -14,7 +14,7 @@ The parameters are ...@@ -14,7 +14,7 @@ The parameters are
base_category_list -- list of category values we need to retrieve base_category_list -- list of category values we need to retrieve
user_name -- string obtained from getSecurityManager().getUser().getId() 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 portal_type -- portal type of object
NOTE: for now, this script requires proxy manager NOTE: for now, this script requires proxy manager
...@@ -22,10 +22,10 @@ NOTE: for now, this script requires proxy manager ...@@ -22,10 +22,10 @@ NOTE: for now, this script requires proxy manager
category_list = [] category_list = []
if object is None: if ob is None:
return [] return []
for base_category in base_category_list: for base_category in base_category_list:
category_list.append({base_category: object.getRelativeUrl()}) category_list.append({base_category: ob.getRelativeUrl()})
return category_list return category_list
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -14,7 +14,7 @@ The parameters are ...@@ -14,7 +14,7 @@ The parameters are
base_category_list -- list of category values we need to retrieve base_category_list -- list of category values we need to retrieve
user_name -- string obtained from getSecurityManager().getUser().getId() 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 portal_type -- portal type of object
NOTE: for now, this script requires proxy manager NOTE: for now, this script requires proxy manager
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -19,7 +19,7 @@ The parameters are ...@@ -19,7 +19,7 @@ The parameters are
base_category_list -- list of category values we need to retrieve base_category_list -- list of category values we need to retrieve
user_name -- string obtained from getSecurityManager().getUser().getId() 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 portal_type -- portal type of object
NOTE: for now, this script requires proxy manager NOTE: for now, this script requires proxy manager
...@@ -27,11 +27,11 @@ NOTE: for now, this script requires proxy manager ...@@ -27,11 +27,11 @@ NOTE: for now, this script requires proxy manager
category_list = [] category_list = []
if object is None: if ob is None:
return [] return []
for base_category in base_category_list: 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}) category_list.append({base_category: membership_list})
return category_list return category_list
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -14,7 +14,7 @@ The parameters are ...@@ -14,7 +14,7 @@ The parameters are
base_category_list -- list of category values we need to retrieve base_category_list -- list of category values we need to retrieve
user_name -- string obtained from getSecurityManager().getUser().getId() 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 portal_type -- portal type of object
NOTE: for now, this script requires proxy manager NOTE: for now, this script requires proxy manager
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -19,7 +19,7 @@ The parameters are ...@@ -19,7 +19,7 @@ The parameters are
base_category_list -- list of category values we need to retrieve base_category_list -- list of category values we need to retrieve
user_name -- string obtained from getSecurityManager().getUser().getId() 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 portal_type -- portal type of object
NOTE: for now, this script requires proxy manager NOTE: for now, this script requires proxy manager
...@@ -27,13 +27,13 @@ NOTE: for now, this script requires proxy manager ...@@ -27,13 +27,13 @@ NOTE: for now, this script requires proxy manager
category_list = [] category_list = []
if object is None: if ob is None:
return [] return []
# Consider all parents of all categories # Consider all parents of all categories
for base_category in base_category_list: for base_category in base_category_list:
member_list = [] member_list = []
for category in object.getAcquiredValueList(base_category): for category in ob.getAcquiredValueList(base_category):
if category.getPortalType() == 'Category': if category.getPortalType() == 'Category':
while category.getPortalType() == 'Category': while category.getPortalType() == 'Category':
member_list.append(category.getRelativeUrl()) member_list.append(category.getRelativeUrl())
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
portal = context.getPortalObject() portal = context.getPortalObject()
Base_translateString = portal.Base_translateString 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) uids = context.portal_selections.getSelectionCheckedUidsFor(selection_name)
# make sure nothing is checked after # make sure nothing is checked after
context.portal_selections.setSelectionCheckedUidsFor(selection_name, []) context.portal_selections.setSelectionCheckedUidsFor(selection_name, [])
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
portal = context.getPortalObject() portal = context.getPortalObject()
Base_translateString = portal.Base_translateString Base_translateString = portal.Base_translateString
def Object_hasRelation(object): def Object_hasRelation(obj):
# Check if there is some related objets. # Check if there is some related objets.
result = 0 result = 0
for o in object.getIndexableChildValueList(): for o in obj.getIndexableChildValueList():
for related in object.portal_categories.getRelatedValueList(object): for related in obj.portal_categories.getRelatedValueList(obj):
if related.getRelativeUrl().startswith(object.getRelativeUrl()): if related.getRelativeUrl().startswith(obj.getRelativeUrl()):
continue continue
elif related.getRelativeUrl().startswith('portal_simulation') : elif related.getRelativeUrl().startswith('portal_simulation') :
continue continue
...@@ -15,7 +15,7 @@ def Object_hasRelation(object): ...@@ -15,7 +15,7 @@ def Object_hasRelation(object):
break break
return result 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) uids = context.portal_selections.getSelectionCheckedUidsFor(selection_name)
# make sure nothing is checked after # make sure nothing is checked after
context.portal_selections.setSelectionCheckedUidsFor(selection_name, []) context.portal_selections.setSelectionCheckedUidsFor(selection_name, [])
...@@ -36,7 +36,6 @@ if uids != []: ...@@ -36,7 +36,6 @@ if uids != []:
else: else:
message = Base_translateString("Sorry, ${count} items are in use.", message = Base_translateString("Sorry, ${count} items are in use.",
mapping={'count': repr(object_used)}) mapping={'count': repr(object_used)})
qs = '?portal_status_message=%s' % message
else: else:
context.manage_cutObjects(uids=uids, REQUEST=request) context.manage_cutObjects(uids=uids, REQUEST=request)
message = Base_translateString("Items cut.") message = Base_translateString("Items cut.")
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -53,18 +53,18 @@ if True: ...@@ -53,18 +53,18 @@ if True:
object_to_remove_list = [] object_to_remove_list = []
object_to_delete_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) 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 # templates inside preference will be unconditionnaly physically
# deleted # deleted
object_to_remove_list.append(object) object_to_remove_list.append(obj)
else: else:
# If a workflow manage a history, # If a workflow manage a history,
# object should not be removed, but only put in state deleted # 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 # Remove some objects
try: try:
...@@ -100,16 +100,15 @@ if True: ...@@ -100,16 +100,15 @@ if True:
# Try to call "delete_action" workflow transition on documents which defined it # 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 # Failure of such a call is not a failure globally. The document was deleted anyway
not_deleted_count = 0 for obj in object_to_delete_list:
for object in object_to_delete_list:
# Hidden transition (without a message displayed) # Hidden transition (without a message displayed)
# are not returned by getActionsFor # are not returned by getActionsFor
try: try:
portal.portal_workflow.doActionFor(object, 'delete_action') portal.portal_workflow.doActionFor(obj, 'delete_action')
except ConflictError: except ConflictError:
raise raise
except: except Exception:
not_deleted_count += 1 pass
# make sure nothing is checked after # make sure nothing is checked after
if selection_name: if selection_name:
......
...@@ -2,8 +2,8 @@ request=context.REQUEST ...@@ -2,8 +2,8 @@ request=context.REQUEST
portal = context.getPortalObject() portal = context.getPortalObject()
Base_translateString = portal.Base_translateString Base_translateString = portal.Base_translateString
selected_uids = context.portal_selections.updateSelectionCheckedUidList(selection_name,listbox_uid,uids) portal.portal_selections.updateSelectionCheckedUidList(selection_name,listbox_uid,uids)
uids = context.portal_selections.getSelectionCheckedUidsFor(selection_name) uids = portal.portal_selections.getSelectionCheckedUidsFor(selection_name)
if uids == []: if uids == []:
message = Base_translateString("Please select one or more items to delete first.") message = Base_translateString("Please select one or more items to delete first.")
...@@ -27,5 +27,5 @@ request.set('proxy_field_id', field_id) ...@@ -27,5 +27,5 @@ request.set('proxy_field_id', field_id)
request.set('proxy_field_selection_name', field_selection_name) request.set('proxy_field_selection_name', field_selection_name)
request.set('ignore_hide_rows', 1) 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) return context.Folder_viewDeleteDialog(uids=uids, REQUEST=request)
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
request = context.REQUEST request = container.REQUEST
stool = context.portal_selections selection_tool = context.portal_selections
if stool.getSelectionInvertModeFor(selection_name): if selection_tool.getSelectionInvertModeFor(selection_name):
# if already in invert mode, toggle invert mode # if already in invert mode, toggle invert mode
stool.setSelectionInvertModeFor(selection_name, invert_mode=0) selection_tool.setSelectionInvertModeFor(selection_name, invert_mode=0)
else: else:
# Set selection to currently checked items, taking into consideration changes # Set selection to currently checked items, taking into consideration changes
# in uids # in uids
selection_uids = stool.getSelectionCheckedUidsFor( selection_uids = selection_tool.getSelectionCheckedUidsFor(
selection_name, REQUEST=request) selection_name, REQUEST=request)
filtered_uid_dict = {} filtered_uid_dict = {}
listbox_uid = map(lambda x:int(x), listbox_uid) listbox_uid = [int(x) for x in listbox_uid]
uids = map (lambda x:int(x), uids) uids = [int(x) for x in uids]
for uid in uids: for uid in uids:
filtered_uid_dict[uid] = 1 filtered_uid_dict[uid] = 1
for uid in selection_uids: for uid in selection_uids:
...@@ -22,10 +22,10 @@ else: ...@@ -22,10 +22,10 @@ else:
filtered_uid_dict[uid] = 1 filtered_uid_dict[uid] = 1
if len(filtered_uid_dict.keys()) > 0 : if len(filtered_uid_dict.keys()) > 0 :
stool.checkAll(selection_name, uids, REQUEST=None) selection_tool.checkAll(selection_name, uids, REQUEST=None)
stool.setSelectionToIds(selection_name, selection_tool.setSelectionToIds(selection_name,
filtered_uid_dict.keys(), REQUEST=request) filtered_uid_dict.keys(), REQUEST=request)
url = stool.getSelectionListUrlFor( url = selection_tool.getSelectionListUrlFor(
selection_name, REQUEST=request) selection_name, REQUEST=request)
request.RESPONSE.redirect(url) request.RESPONSE.redirect(url)
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
from Products.ERP5Form.Report import ReportSection from Products.ERP5Form.Report import ReportSection
from Products.ERP5Type.Message import Message
form = context
request = context.REQUEST request = context.REQUEST
report_section_list = [] report_section_list = []
portal = context.getPortalObject() portal = context.getPortalObject()
......
...@@ -9,9 +9,7 @@ if context.getPortalType() == 'Preference': ...@@ -9,9 +9,7 @@ if context.getPortalType() == 'Preference':
result.append(i) result.append(i)
return result return result
else: else:
return list( # kw can contain limit, sort_on and similar runtime information
filter(lambda x: x.getRelationCountForDeletion() == 0, # only docs WITHOUT relations can be deleted object_list = [x.getObject() for x in context.portal_catalog(uid=uid, **kw)]
map(lambda x: x.getObject(), # only docs WITHOUT relations can be deleted
context.portal_catalog(uid=uid, **kw)) # kw can contain limit, sort_on and similar runtime information return [x for x in object_list if x.getRelationCountForDeletion() == 0]
)
)
...@@ -6,7 +6,6 @@ This script is intended as a dialog target. ...@@ -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 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 :param mass_workflow_action: {str} the ID of (worflow) action to execute on each object
""" """
MARKER = []
portal = context.getPortalObject() portal = context.getPortalObject()
request = kwargs.get("REQUEST", None) or context.REQUEST request = kwargs.get("REQUEST", None) or context.REQUEST
......
...@@ -9,7 +9,7 @@ if context.cb_dataValid: ...@@ -9,7 +9,7 @@ if context.cb_dataValid:
else: else:
if portal_type_set.issubset(context.getVisibleAllowedContentTypeList()): if portal_type_set.issubset(context.getVisibleAllowedContentTypeList()):
try: try:
new_item_list = context.manage_pasteObjects(portal.REQUEST['__cp']) context.manage_pasteObjects(portal.REQUEST['__cp'])
except KeyError: except KeyError:
error_message = 'Nothing to paste.' error_message = 'Nothing to paste.'
else: else:
......
...@@ -2,11 +2,6 @@ request = container.REQUEST ...@@ -2,11 +2,6 @@ request = container.REQUEST
from Products.ZSQLCatalog.SQLCatalog import Query, NegatedQuery, ComplexQuery 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 # Convert mapping from request.form into something the catalog can understand
# This script uses ad-hoc values that are understood by # This script uses ad-hoc values that are understood by
# Folder_viewSearchDialog: x_value_ and x_usage_ are used to remember what was # Folder_viewSearchDialog: x_value_ and x_usage_ are used to remember what was
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# - Implement validation of matrix fields # - Implement validation of matrix fields
# - Implement validation of list fields # - Implement validation of list fields
# #
from Products.Formulator.Errors import ValidationError, FormValidationError from Products.Formulator.Errors import FormValidationError
from ZTUtils import make_query from ZTUtils import make_query
request=context.REQUEST request=context.REQUEST
...@@ -34,12 +34,12 @@ try: ...@@ -34,12 +34,12 @@ try:
listbox_field = form.get_field('listbox') listbox_field = form.get_field('listbox')
gv = {} gv = {}
if listbox_field.has_value('global_attributes'): 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: for k in hidden_attributes:
gv[k] = getattr(request, k,None) gv[k] = getattr(request, k,None)
for property, v in listbox.items(): for property_, v in listbox.items():
v.update(gv) v.update(gv)
context.setCriterion(property, **v) context.setCriterion(property_, **v)
# Update basic attributes # Update basic attributes
context.edit(REQUEST=request, edit_order=edit_order, **kw) context.edit(REQUEST=request, edit_order=edit_order, **kw)
context.reindexObject() context.reindexObject()
......
""" """
This script is used in parallel list fields in Predicate_view 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 # Initialise result
sub_field_list = [] sub_field_list = []
...@@ -28,6 +30,4 @@ for category in category_list: ...@@ -28,6 +30,4 @@ for category in category_list:
z += 1 z += 1
sub_field_list.append(new_dict) sub_field_list.append(new_dict)
request = context.REQUEST
return sub_field_list return sub_field_list
...@@ -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>
......
portal = context.getPortalObject()
N_ = portal.Base_translateString
request = container.REQUEST request = container.REQUEST
style = request.get('your_portal_skin', style = request.get('your_portal_skin',
......
...@@ -7,7 +7,6 @@ from Products.ERP5Type.Document import newTempBase ...@@ -7,7 +7,6 @@ from Products.ERP5Type.Document import newTempBase
# get all cache statistics # get all cache statistics
cache_stats = context.getPortalObject().portal_caches.getCacheTotalMemorySize() cache_stats = context.getPortalObject().portal_caches.getCacheTotalMemorySize()
cache_factory_list_stats = cache_stats['stats'] cache_factory_list_stats = cache_stats['stats']
cache_plugin_id = context.getId()
cache_factory_id = context.getParentValue().getId() cache_factory_id = context.getParentValue().getId()
cache_plugin_stats = cache_factory_list_stats.get( cache_plugin_stats = cache_factory_list_stats.get(
cache_factory_id, cache_factory_id,
......
if default_sub_field_property_dict is None:
default_sub_field_property_dict = {}
# Remove empty items # Remove empty items
item_list = filter(lambda x: x not in [('',''), ['','']], item_list = [x for x in item_list if x not in (('',''), ['',''])]
item_list)
sub_field_dict = {} sub_field_dict = {}
split_depth = 1 split_depth = 1
......
...@@ -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>
......
# nothing (we don't want to reset priority like in Preference_afterClone) # nothing (we don't want to reset priority like in Preference_afterClone)
pass
...@@ -12,8 +12,8 @@ if len(uids) == 0: ...@@ -12,8 +12,8 @@ if len(uids) == 0:
id_list = [] id_list = []
for uid in uids: for uid in uids:
repository, id = context.decodeRepositoryBusinessTemplateUid(uid) repository, id_ = context.decodeRepositoryBusinessTemplateUid(uid)
bt = context.download('/'.join([repository, id])) bt = context.download('/'.join([repository, id_]))
id_list.append(bt.getId()) id_list.append(bt.getId())
RESPONSE.redirect("%s?portal_status_message=Business+Templates+Downloaded+As:+%s" % (ret_url, ',+'.join(id_list))) 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 ...@@ -3,7 +3,6 @@ update_catalog = update_translation = 0
bt_id_list = getattr(context.REQUEST, 'bt_list', ()) bt_id_list = getattr(context.REQUEST, 'bt_list', ())
bt_dict = {} bt_dict = {}
object_to_update = {}
for item in listbox: for item in listbox:
# backward compatibility # backward compatibility
if not same_type(item['choice'], []): if not same_type(item['choice'], []):
......
...@@ -73,8 +73,8 @@ tuple_list = context.sortBusinessTemplateList(tuple_list) ...@@ -73,8 +73,8 @@ tuple_list = context.sortBusinessTemplateList(tuple_list)
bt_list = [] bt_list = []
for repository, id in tuple_list: for repository, id_ in tuple_list:
bt = context.download('/'.join([repository, id])) bt = context.download('/'.join([repository, id_]))
bt_list.append(bt.getId()) bt_list.append(bt.getId())
RESPONSE.redirect( RESPONSE.redirect(
......
...@@ -12,7 +12,6 @@ from zExceptions import Unauthorized ...@@ -12,7 +12,6 @@ from zExceptions import Unauthorized
portal = context.getPortalObject() portal = context.getPortalObject()
portal_diff = portal.portal_diff portal_diff = portal.portal_diff
request = context.REQUEST request = context.REQUEST
object_revision_list = []
history_size = portal.portal_preferences.getPreferredHtmlStyleZodbHistorySize() history_size = portal.portal_preferences.getPreferredHtmlStyleZodbHistorySize()
first_object = None first_object = None
...@@ -105,7 +104,7 @@ if ((first_path is None and second_path is None) and ...@@ -105,7 +104,7 @@ if ((first_path is None and second_path is None) and
first_object = selected_object_list[0] first_object = selected_object_list[0]
second_object = selected_object_list[1] 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 # These 2 objects can be revisions of same object, 2 different revisions of
# different objects or 2 current ERP5 object. # different objects or 2 current ERP5 object.
if first_object and second_object: if first_object and second_object:
......
object = state_change['object'] state_change['object'].Base_checkConsistency()
object.Base_checkConsistency()
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