Commit 0b0b2126 authored by Jérome Perrin's avatar Jérome Perrin

dms: fix pylint messages and enable coding style test

parent bd601780
...@@ -115,7 +115,7 @@ class PDFDocument(Image): ...@@ -115,7 +115,7 @@ class PDFDocument(Image):
return outputStream.getvalue() return outputStream.getvalue()
# Conversion API # Conversion API
def _convert(self, format, **kw): def _convert(self, format, **kw): # pylint: disable=redefined-builtin
""" """
Implementation of conversion for PDF files Implementation of conversion for PDF files
""" """
...@@ -164,7 +164,7 @@ class PDFDocument(Image): ...@@ -164,7 +164,7 @@ class PDFDocument(Image):
raise NotImplementedError raise NotImplementedError
security.declarePrivate('_convertToText') security.declarePrivate('_convertToText')
def _convertToText(self): def _convertToText(self, format='txt'): # pylint: disable=redefined-builtin
""" """
Convert the PDF text content to text with pdftotext Convert the PDF text content to text with pdftotext
""" """
...@@ -346,9 +346,9 @@ class PDFDocument(Image): ...@@ -346,9 +346,9 @@ class PDFDocument(Image):
self._content_information = result self._content_information = result
return result.copy() return result.copy()
def _setFile(self, data, precondition=None): def _setFile(self, *args, **kw):
try: try:
del self._content_information del self._content_information
except (AttributeError, KeyError): except (AttributeError, KeyError):
pass pass
Image._setFile(self, data, precondition=precondition) Image._setFile(self, *args, **kw)
...@@ -6,6 +6,12 @@ ...@@ -6,6 +6,12 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>PDFDocument</string> </value> <value> <string>PDFDocument</string> </value>
...@@ -43,11 +49,7 @@ ...@@ -43,11 +49,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:117, 21: Redefining built-in \'format\' (redefined-builtin)</string>
<string>W:166, 2: Arguments number differs from overridden \'_convertToText\' method (arguments-differ)</string>
<string>W:348, 2: Arguments number differs from overridden \'_setFile\' method (arguments-differ)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
...@@ -57,13 +59,28 @@ ...@@ -57,13 +59,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -76,7 +93,7 @@ ...@@ -76,7 +93,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -85,7 +102,7 @@ ...@@ -85,7 +102,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
......
...@@ -71,7 +71,7 @@ def mkProxy(self): ...@@ -71,7 +71,7 @@ def mkProxy(self):
sp = xmlrpclib.ServerProxy('http://%s:%d' % (adr,nr), allow_none=True) sp = xmlrpclib.ServerProxy('http://%s:%d' % (adr,nr), allow_none=True)
return sp return sp
def generateFile(self, name, data, format): def generateFile(self, name, data, format): # pylint: disable=redefined-builtin
sp = mkProxy(self) sp = mkProxy(self)
kw = sp.run_generate(name, data, None, format) kw = sp.run_generate(name, data, None, format)
res = base64.decodestring(kw['data']) res = base64.decodestring(kw['data'])
...@@ -92,7 +92,7 @@ def getLastWorkflowDate(self, state_name='simulation_state', state=('released',' ...@@ -92,7 +92,7 @@ def getLastWorkflowDate(self, state_name='simulation_state', state=('released','
or JP says "there is an API for it" and we trash this one''' or JP says "there is an API for it" and we trash this one'''
if not hasattr(self, 'workflow_history'): if not hasattr(self, 'workflow_history'):
return None return None
for name,wflow in self.workflow_history.items(): for wflow in self.workflow_history.values():
if wflow is None or len(wflow) == 0: continue # empty history if wflow is None or len(wflow) == 0: continue # empty history
if wflow[0].get(state_name) is None: continue # not the right one if wflow[0].get(state_name) is None: continue # not the right one
for i in range(len(wflow)): for i in range(len(wflow)):
...@@ -110,7 +110,7 @@ def findAddress(txt): ...@@ -110,7 +110,7 @@ def findAddress(txt):
""" """
find email address in a string find email address in a string
""" """
validchars='0-9A-Za-z.\-_' validchars = r'0-9A-Za-z.\-_'
r=re.compile('[%s]+@[%s]+' % (validchars,validchars)) r=re.compile('[%s]+@[%s]+' % (validchars,validchars))
m=r.search(txt) m=r.search(txt)
return m and m.group() return m and m.group()
...@@ -121,7 +121,7 @@ def extractParams(txt): ...@@ -121,7 +121,7 @@ def extractParams(txt):
We assume that parameters are given as lines of the format: We assume that parameters are given as lines of the format:
name:value name:value
""" """
r=re.compile('^([\w_]+):([\w_/]+)$') r = re.compile(r'^([\w_]+):([\w_/]+)$')
res=[] res=[]
for line in txt.split(): for line in txt.split():
found=r.findall(line.strip()) found=r.findall(line.strip())
......
...@@ -6,10 +6,22 @@ ...@@ -6,10 +6,22 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>DocumentManagement</string> </value> <value> <string>DocumentManagement</string> </value>
</item> </item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>extension.erp5.DocumentManagement</string> </value> <value> <string>extension.erp5.DocumentManagement</string> </value>
...@@ -24,6 +36,18 @@ ...@@ -24,6 +36,18 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item> <item>
<key> <string>version</string> </key> <key> <string>version</string> </key>
<value> <string>erp5</string> </value> <value> <string>erp5</string> </value>
...@@ -31,13 +55,28 @@ ...@@ -31,13 +55,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -50,7 +89,7 @@ ...@@ -50,7 +89,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -59,26 +98,30 @@ ...@@ -59,26 +98,30 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<list> <key> <string>_log</string> </key>
<dictionary> <value>
<item> <list>
<key> <string>action</string> </key> <dictionary>
<value> <string>validate</string> </value> <item>
</item> <key> <string>action</string> </key>
<item> <value> <string>validate</string> </value>
<key> <string>validation_state</string> </key> </item>
<value> <string>validated</string> </value> <item>
</item> <key> <string>validation_state</string> </key>
</dictionary> <value> <string>validated</string> </value>
</list> </item>
</tuple> </dictionary>
</list>
</value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
############################################################################## ##############################################################################
def getPersonRoleList(self, person, object): def getPersonRoleList(self, person, object): # pylint: disable=redefined-builtin
""" """
Get list of local roles for user. Get list of local roles for user.
""" """
......
...@@ -6,10 +6,22 @@ ...@@ -6,10 +6,22 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>DocumentSecurity</string> </value> <value> <string>DocumentSecurity</string> </value>
</item> </item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>extension.erp5.DocumentSecurity</string> </value> <value> <string>extension.erp5.DocumentSecurity</string> </value>
...@@ -24,6 +36,18 @@ ...@@ -24,6 +36,18 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item> <item>
<key> <string>version</string> </key> <key> <string>version</string> </key>
<value> <string>erp5</string> </value> <value> <string>erp5</string> </value>
...@@ -31,13 +55,28 @@ ...@@ -31,13 +55,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -50,7 +89,7 @@ ...@@ -50,7 +89,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -59,26 +98,30 @@ ...@@ -59,26 +98,30 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<list> <key> <string>_log</string> </key>
<dictionary> <value>
<item> <list>
<key> <string>action</string> </key> <dictionary>
<value> <string>validate</string> </value> <item>
</item> <key> <string>action</string> </key>
<item> <value> <string>validate</string> </value>
<key> <string>validation_state</string> </key> </item>
<value> <string>validated</string> </value> <item>
</item> <key> <string>validation_state</string> </key>
</dictionary> <value> <string>validated</string> </value>
</list> </item>
</tuple> </dictionary>
</list>
</value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
...@@ -27,7 +27,7 @@ for frequency_reference, creation_date in date_dict.items(): ...@@ -27,7 +27,7 @@ for frequency_reference, creation_date in date_dict.items():
max_in_activities = 1000 max_in_activities = 1000
offset = 0 offset = 0
loop = documents_to_update / max_in_activities loop = documents_to_update / max_in_activities
for i in range(loop): for _ in range(loop):
limit = '%s,%s' % (offset, max_in_activities) limit = '%s,%s' % (offset, max_in_activities)
sql_kw['limit'] = limit sql_kw['limit'] = limit
updateDocumentList(**sql_kw) updateDocumentList(**sql_kw)
......
...@@ -6,5 +6,4 @@ if I don't have permissions to access the object) ...@@ -6,5 +6,4 @@ if I don't have permissions to access the object)
object_list = context.Base_getRelatedObjectValueList(base_category, portal_type_list) object_list = context.Base_getRelatedObjectValueList(base_category, portal_type_list)
title_list = [o.getTitle() for o in object_list] title_list = [o.getTitle() for o in object_list]
return [t for t in title_list if t != '']
return filter(lambda t:t!='', title_list)
...@@ -10,8 +10,8 @@ nr_of_types = len(type_list) ...@@ -10,8 +10,8 @@ nr_of_types = len(type_list)
basecatdict = {} basecatdict = {}
for type in type_list: for type_info in type_list:
type_base_cat_list = context.portal_types[type].getInstanceBaseCategoryList() type_base_cat_list = context.portal_types[type_info].getInstanceBaseCategoryList()
for base_cat in type_base_cat_list: for base_cat in type_base_cat_list:
basecatdict[base_cat] = basecatdict.setdefault(base_cat, 0)+1 basecatdict[base_cat] = basecatdict.setdefault(base_cat, 0)+1
......
# this script has an `format` argument
# pylint: disable=redefined-builtin
""" """
Generic method to handle conversion failures ans still return something to use Generic method to handle conversion failures ans still return something to use
to explain what when wrong, etc. to explain what when wrong, etc.
......
...@@ -12,8 +12,7 @@ version of each of them. ...@@ -12,8 +12,7 @@ version of each of them.
# Document_getSimilarityCloud = Document_get + upperCase(cloud) + ValueList # Document_getSimilarityCloud = Document_get + upperCase(cloud) + ValueList
# BG - not much use, they're too different # BG - not much use, they're too different
from Products.ERP5Type.Utils import convertToUpperCase, convertToMixedCase from Products.ERP5Type.Utils import convertToUpperCase
from Products.ERP5Type.Log import log
def getRelatedLatest(category): def getRelatedLatest(category):
funcname = 'get%sValueList' % convertToUpperCase(category) funcname = 'get%sValueList' % convertToUpperCase(category)
...@@ -44,5 +43,4 @@ if relation_id == 'all': ...@@ -44,5 +43,4 @@ if relation_id == 'all':
dic[obj] = None dic[obj] = None
return dic.keys() return dic.keys()
log('Relation %s is not provided for in this script' % relation)
return [] # failover - undefined relation return [] # failover - undefined relation
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
from Products.ERP5Type.Cache import CachingMethod from Products.ERP5Type.Cache import CachingMethod
def cached_DMSGetItemList(base_category): def cached_DMSGetItemList(base_category):
basecatobject = context.portal_categories.resolveCategory(base_category) basecatobject = context.portal_categories.resolveCategory(base_category)
return basecatobject.getCategoryChildLogicalPathItemList() return basecatobject.getCategoryChildLogicalPathItemList()
cached_DMSGetItemList = CachingMethod(cached_DMSGetItemList, id='DMGetItemListCachedMethodWhatever') cached_DMSGetItemList = CachingMethod(cached_DMSGetItemList, id='DMGetItemListCachedMethodWhatever')
...@@ -26,7 +26,6 @@ if default_sub_field_property_dict is None: ...@@ -26,7 +26,6 @@ if default_sub_field_property_dict is None:
} }
sub_field_dict = {} sub_field_dict = {}
maximum_list_size = 5
default_sub_field_property_dict['field_type'] = 'ListField' default_sub_field_property_dict['field_type'] = 'ListField'
default_sub_field_property_dict['size'] = 1 default_sub_field_property_dict['size'] = 1
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
in such way that it is possible to select multiple in such way that it is possible to select multiple
group categories for the same document group 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 = []
...@@ -16,7 +18,7 @@ default_sub_field_property_dict.update({ ...@@ -16,7 +18,7 @@ default_sub_field_property_dict.update({
}) })
z = 0 z = 0
for i in range(1): for _ in range(1):
new_dict = default_sub_field_property_dict.copy() new_dict = default_sub_field_property_dict.copy()
new_dict['title'] = '&nbsp;' new_dict['title'] = '&nbsp;'
new_dict['key'] = str(z) new_dict['key'] = str(z)
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>item_list, value_list, default_sub_field_property_dict={}, is_right_display=0</string> </value> <value> <string>item_list, value_list, default_sub_field_property_dict=None, is_right_display=0</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
in such way that it is possible to select multiple in such way that it is possible to select multiple
function categories for the same document function 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 = []
...@@ -16,7 +18,7 @@ default_sub_field_property_dict.update({ ...@@ -16,7 +18,7 @@ default_sub_field_property_dict.update({
}) })
z = 0 z = 0
for i in range(1): for _ in range(1):
new_dict = default_sub_field_property_dict.copy() new_dict = default_sub_field_property_dict.copy()
new_dict['title'] = '&nbsp;' new_dict['title'] = '&nbsp;'
new_dict['key'] = str(z) new_dict['key'] = str(z)
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>item_list, value_list, default_sub_field_property_dict={}, is_right_display=0</string> </value> <value> <string>item_list, value_list, default_sub_field_property_dict=None, is_right_display=0</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
in such way that it is possible to select multiple in such way that it is possible to select multiple
site categories for the same document site 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 = []
...@@ -16,7 +18,7 @@ default_sub_field_property_dict.update({ ...@@ -16,7 +18,7 @@ default_sub_field_property_dict.update({
}) })
z = 0 z = 0
for i in range(1): for _ in range(1):
new_dict = default_sub_field_property_dict.copy() new_dict = default_sub_field_property_dict.copy()
new_dict['title'] = '&nbsp;' new_dict['title'] = '&nbsp;'
new_dict['key'] = str(z) new_dict['key'] = str(z)
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>item_list, value_list, default_sub_field_property_dict={}, is_right_display=0</string> </value> <value> <string>item_list, value_list, default_sub_field_property_dict=None, is_right_display=0</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -19,8 +19,6 @@ if context.getExternalProcessingState() not in ('converted', 'empty'): ...@@ -19,8 +19,6 @@ if context.getExternalProcessingState() not in ('converted', 'empty'):
message = 'Socket Error: %s' % (repr(e) or 'undefined.') message = 'Socket Error: %s' % (repr(e) or 'undefined.')
except Exception, e: except Exception, e:
message = 'Problem: %s' % (repr(e) or 'undefined.') message = 'Problem: %s' % (repr(e) or 'undefined.')
except:
message = 'Problem: unknown'
# reach here, then exception was raised, message must be logged in workflow # reach here, then exception was raised, message must be logged in workflow
# do not simply raise but rather change external processing state # do not simply raise but rather change external processing state
# so user will see something is wrong # so user will see something is wrong
......
...@@ -11,8 +11,6 @@ except ConversionError, e: ...@@ -11,8 +11,6 @@ except ConversionError, e:
message = 'Conversion Error: %s' % (str(e) or 'undefined.') message = 'Conversion Error: %s' % (str(e) or 'undefined.')
except Exception, e: except Exception, e:
message = 'Problem: %s' % (repr(e) or 'undefined.') message = 'Problem: %s' % (repr(e) or 'undefined.')
except:
message = 'Problem: unknown'
# reach here, then exception was raised, message must be logged in workflow # reach here, then exception was raised, message must be logged in workflow
# do not simply raise but rather change external processing state # do not simply raise but rather change external processing state
......
# this script has an `file` argument
# pylint: disable=redefined-builtin
""" """
This script is called when a file is uploaded to an object via ERP5 standard interface. This script is called when a file is uploaded to an object via ERP5 standard interface.
It does the following: It does the following:
...@@ -9,9 +11,9 @@ Otherwise it just uploads the file, bumps up revision number and calls metadata ...@@ -9,9 +11,9 @@ Otherwise it just uploads the file, bumps up revision number and calls metadata
""" """
from Products.ERP5Type.Log import log, WARNING from Products.ERP5Type.Log import log, WARNING
from Products.ERP5Type.Message import translateString
translate = context.Base_translateString translate = context.Base_translateString
request = context.REQUEST
current_type = context.getPortalType() current_type = context.getPortalType()
file_name = file.filename file_name = file.filename
......
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
only the group the user is directly assigned to (not the whole group hierarchy path). only the group the user is directly assigned to (not the whole group hierarchy path).
""" """
return context.ERP5Type_getSecurityCategoryFromAssignmentTree(base_category_list, user_name, object, portal_type, strict=True) return context.ERP5Type_getSecurityCategoryFromAssignmentTree(base_category_list, user_name, obj, portal_type, strict=True)
...@@ -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, obj, portal_type</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>base_category_list, user_name, object, portal_type, strict=False, root=False</string> </value> <value> <string>base_category_list, user_name, obj, portal_type, strict=False, root=False</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -5,7 +5,7 @@ of the document (e.g. in Memo type). ...@@ -5,7 +5,7 @@ of the document (e.g. in Memo type).
from Products.ERP5Type.Log import log from Products.ERP5Type.Log import log
category_list = [] category_list = []
for ob in object.getDestinationValueList(): for ob in obj.getDestinationValueList():
category_dict = {} category_dict = {}
for base_category in base_category_list: for base_category in base_category_list:
if base_category == 'group': if base_category == 'group':
......
...@@ -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, obj, portal_type</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -6,7 +6,7 @@ is addressed to (destination). Can be multiple destination persons. ...@@ -6,7 +6,7 @@ is addressed to (destination). Can be multiple destination persons.
category_list = [] category_list = []
# We look for valid assignments of destination users # We look for valid assignments of destination users
for person_object in object.getDestinationValueList(portal_type='Person'): for person_object in obj.getDestinationValueList(portal_type='Person'):
for assignment in person_object.contentValues(filter={'portal_type': 'Assignment'}): for assignment in person_object.contentValues(filter={'portal_type': 'Assignment'}):
if assignment.getValidationState() == 'open': if assignment.getValidationState() == 'open':
category_dict = {} category_dict = {}
...@@ -18,7 +18,7 @@ for person_object in object.getDestinationValueList(portal_type='Person'): ...@@ -18,7 +18,7 @@ for person_object in object.getDestinationValueList(portal_type='Person'):
if category_value not in (None, ''): if category_value not in (None, ''):
category_dict[base_category] = category_value category_dict[base_category] = category_value
else: else:
raise RuntimeError, "Error: '%s' property is required in order to update person security group" % (base_category) raise RuntimeError("Error: '%s' property is required in order to update person security group" % (base_category))
category_list.append(category_dict) category_list.append(category_dict)
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, obj, portal_type</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -8,10 +8,8 @@ Person, just take from the object. ...@@ -8,10 +8,8 @@ Person, just take from the object.
category_list = [] category_list = []
person_object = object
# We look for valid assignments of this user # We look for valid assignments of this user
for assignment in person_object.contentValues(filter={'portal_type': 'Assignment'}): for assignment in obj.contentValues(filter={'portal_type': 'Assignment'}):
if assignment.getValidationState() == 'open': if assignment.getValidationState() == 'open':
category_dict = {} category_dict = {}
for base_category in base_category_list: for base_category in base_category_list:
...@@ -22,7 +20,7 @@ for assignment in person_object.contentValues(filter={'portal_type': 'Assignment ...@@ -22,7 +20,7 @@ for assignment in person_object.contentValues(filter={'portal_type': 'Assignment
if category_value not in (None, ''): if category_value not in (None, ''):
category_dict[base_category] = category_value category_dict[base_category] = category_value
else: else:
raise RuntimeError, "Error: '%s' property is required in order to update person security group" % (base_category) raise RuntimeError("Error: '%s' property is required in order to update person security group" % (base_category))
category_list.append(category_dict) category_list.append(category_dict)
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, obj, portal_type</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>base_category_list, user_name, object, portal_type</string> </value> <value> <string>base_category_list, user_name, obj, portal_type</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -6,4 +6,4 @@ in the certain organisation - for this, all we need is the first part ...@@ -6,4 +6,4 @@ in the certain organisation - for this, all we need is the first part
of the group category. of the group category.
""" """
return context.ERP5Type_getSecurityCategoryFromAssignmentTree(base_category_list, user_name, object, portal_type, strict=True, root=True) return context.ERP5Type_getSecurityCategoryFromAssignmentTree(base_category_list, user_name, obj, portal_type, strict=True, root=True)
...@@ -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, obj, portal_type</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -4,5 +4,11 @@ if brain.getValidationState() == 'embedded': ...@@ -4,5 +4,11 @@ if brain.getValidationState() == 'embedded':
reference = brain.getId() reference = brain.getId()
else: else:
reference = brain.getReference() reference = brain.getReference()
format = context.getPortalObject().portal_preferences.getPreferredImageFormat()
return unicode("javascript:SelectFile('%s?format=%s')" % (reference.replace("'", "\\'"), format), 'utf-8') return unicode(
"javascript:SelectFile('%s?format=%s')" % (
reference.replace("'", "\\'"),
context.getPortalObject().portal_preferences.getPreferredImageFormat()
),
'utf-8',
)
# this script has an `format` argument
# pylint: disable=redefined-builtin
if format in ('svg',): if format in ('svg',):
image_pixels = context.getHeight()* context.getWidth() image_pixels = context.getHeight()* context.getWidth()
max_pixels = 128*128 # default thumbnail size max_pixels = 128*128 # default thumbnail size
......
# this script has an `format` argument
# pylint: disable=redefined-builtin
""" """
Convert Image (context) to a desired format and return as a binary `filename` file. Convert Image (context) to a desired format and return as a binary `filename` file.
Requires format and desired filename (adds extension if missing). Requires format and desired filename (adds extension if missing).
......
# this script has an `format` argument
# pylint: disable=redefined-builtin
""" """
Convert OOoDocument (context) to a desired format and return as a binary `filename` file. Convert OOoDocument (context) to a desired format and return as a binary `filename` file.
Requires format and desired filename (adds extension if missing). Requires format and desired filename (adds extension if missing).
......
# this script has an `format` argument
# pylint: disable=redefined-builtin
from Products.ERP5.Document.Document import VALID_IMAGE_FORMAT_LIST from Products.ERP5.Document.Document import VALID_IMAGE_FORMAT_LIST
if format in VALID_IMAGE_FORMAT_LIST: if format in VALID_IMAGE_FORMAT_LIST:
......
content_information = context.getContentInformation() content_information = context.getContentInformation()
number_of_pages = int(content_information.get('Pages', 1)) number_of_pages = int(content_information.get('Pages', 1))
max = number_of_pages - 1 max_ = number_of_pages - 1
selection_index = int(selection_index) selection_index = int(selection_index)
if selection_index > max: if selection_index > max_:
return max return max_
elif -max > selection_index: elif -max_ > selection_index:
return 0 return 0
elif selection_index < 0: elif selection_index < 0:
return max + selection_index + 1 return max_ + selection_index + 1
else: else:
return selection_index return selection_index
message = state_change.kwargs['reply_body'] message = state_change.kwargs['reply_body']
subject = state_change.kwargs['reply_subject'] subject = state_change.kwargs['reply_subject']
recipient = state_change.kwargs['reply_to'] recipient = state_change.kwargs['reply_to']
object = state_change['object'] event = state_change['object']
state_change['object'].MailHost.send(message, mto=recipient, event.MailHost.send(
mfrom=object.portal_preferences.getPreferredEventSenderEmail(), message,
subject=subject) mto=recipient,
mfrom=event.portal_preferences.getPreferredEventSenderEmail(),
subject=subject)
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>state_change, validation_state=[\'published\', \'published_alive\', \'released\', \'released_alive\', \'shared\', \'shared_alive\'], now=None</string> </value> <value> <string>state_change, validation_state=(\'published\', \'published_alive\', \'released\', \'released_alive\', \'shared\', \'shared_alive\'), now=None</string> </value>
</item> </item>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</string> </key>
......
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