Commit 4558c52d authored by Jérome Perrin's avatar Jérome Perrin

Make coding style install less business templates

Move `BusinessTemplate_getPythonSourceCodeMessageList` to `erp5_core`, so that coding style tests don't need to install `erp5_administration` and all its dependencies.

`erp5_core` is not the final place for this, because this is not required to for business template bootstrap, but this is temporary until we finish business template reorganisation.

This revealed several problems of wrong dependencies between business templates that we could not see before, when coding style was installing too many business templates such as `erp5_pdm`, `erp5_trade`, `erp5_simulation`, `erp5_project`.

See merge request !1089
parents b78241cd 1c05093c
erp5_base >= 0.8.3 erp5_base >= 0.8.3
erp5_core >= 1.0rc13 erp5_core >= 1.0rc13
\ No newline at end of file erp5_simulation
\ No newline at end of file
...@@ -173,52 +173,6 @@ def checkConversionToolAvailability(self): ...@@ -173,52 +173,6 @@ def checkConversionToolAvailability(self):
result.edit(severity=severity) result.edit(severity=severity)
active_process.postResult(result) active_process.postResult(result)
from Products.ERP5Type.Utils import checkPythonSourceCode
def checkPythonSourceCodeAsJSON(self, data, REQUEST=None):
"""
Check Python source suitable for Source Code Editor and return a JSON object
"""
import json
# XXX data is encoded as json, because jQuery serialize lists as []
if isinstance(data, basestring):
data = json.loads(data)
# data contains the code, the bound names and the script params. From this
# we reconstruct a function that can be checked
def indent(text):
return ''.join((" " + line) for line in text.splitlines(True))
is_python_script = 'bound_names' in data
if is_python_script:
signature_parts = data['bound_names']
if data['params']:
signature_parts += [data['params']]
signature = ", ".join(signature_parts)
function_name = "function_name"
body = "def %s(%s):\n%s" % (function_name,
signature,
indent(data['code']) or " pass")
else:
body = data['code']
message_list = checkPythonSourceCode(body.encode('utf8'), data.get('portal_type'))
for message_dict in message_list:
if is_python_script:
message_dict['row'] = message_dict['row'] - 2
else:
message_dict['row'] = message_dict['row'] - 1
if message_dict['type'] in ('E', 'F'):
message_dict['type'] = 'error'
else:
message_dict['type'] = 'warning'
if REQUEST is not None:
REQUEST.RESPONSE.setHeader('content-type', 'application/json')
return json.dumps(dict(annotations=message_list))
def filterSecurityUidDict(security_uid_dict, referenced_security_uid_set): def filterSecurityUidDict(security_uid_dict, referenced_security_uid_set):
""" """
......
...@@ -7,5 +7,4 @@ document.erp5.ApparelMeasurement ...@@ -7,5 +7,4 @@ document.erp5.ApparelMeasurement
document.erp5.ApparelModel document.erp5.ApparelModel
document.erp5.ApparelShape document.erp5.ApparelShape
document.erp5.ApparelSize document.erp5.ApparelSize
document.erp5.Consumption
document.erp5.VariationImage document.erp5.VariationImage
\ No newline at end of file
portal_components/document.erp5.Consumption
\ No newline at end of file
...@@ -66,7 +66,6 @@ ...@@ -66,7 +66,6 @@
<item>Causality Movement Group</item> <item>Causality Movement Group</item>
<item>Day Movement Group</item> <item>Day Movement Group</item>
<item>Delivery Causality Assignment Movement Group</item> <item>Delivery Causality Assignment Movement Group</item>
<item>First Causality Movement Group</item>
<item>Invoice Movement Group</item> <item>Invoice Movement Group</item>
<item>Monthly Range Movement Group</item> <item>Monthly Range Movement Group</item>
<item>Nested Line Movement Group</item> <item>Nested Line Movement Group</item>
...@@ -129,7 +128,4 @@ ...@@ -129,7 +128,4 @@
<portal_type id="Rounding Tool"> <portal_type id="Rounding Tool">
<item>Rounding Model</item> <item>Rounding Model</item>
</portal_type> </portal_type>
<portal_type id="Solver Tool">
<item>Solver Type</item>
</portal_type>
</allowed_content_type_list> </allowed_content_type_list>
\ No newline at end of file
...@@ -40,7 +40,6 @@ Order Builder | Causality Assignment Movement Group ...@@ -40,7 +40,6 @@ Order Builder | Causality Assignment Movement Group
Order Builder | Causality Movement Group Order Builder | Causality Movement Group
Order Builder | Day Movement Group Order Builder | Day Movement Group
Order Builder | Delivery Causality Assignment Movement Group Order Builder | Delivery Causality Assignment Movement Group
Order Builder | First Causality Movement Group
Order Builder | Invoice Movement Group Order Builder | Invoice Movement Group
Order Builder | Monthly Range Movement Group Order Builder | Monthly Range Movement Group
Order Builder | Nested Line Movement Group Order Builder | Nested Line Movement Group
...@@ -87,5 +86,4 @@ Person | Fax ...@@ -87,5 +86,4 @@ Person | Fax
Person | Link Person | Link
Person | Telephone Person | Telephone
Query Module | Query Query Module | Query
Rounding Tool | Rounding Model Rounding Tool | Rounding Model
Solver Tool | Solver Type \ No newline at end of file
\ No newline at end of file
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>Component_getErrorWarningMessageDictAsJson</string> </value> <value> <string>ComponentMixin_getErrorWarningMessageDictAsJson</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ComponentMixin_getTextContentHistoryRevisionDictListAsJSON</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -159,7 +159,7 @@ ...@@ -159,7 +159,7 @@
$.ajax({type: 'GET', $.ajax({type: 'GET',
async: false, async: false,
url: 'Component_getErrorWarningMessageDictAsJson', url: 'ComponentMixin_getErrorWarningMessageDictAsJson',
success: getErrorWarningMessageDictHandler}); success: getErrorWarningMessageDictHandler});
} }
...@@ -651,7 +651,7 @@ ...@@ -651,7 +651,7 @@
$.ajax({type: 'GET', $.ajax({type: 'GET',
async: true, async: true,
dataType: 'json', dataType: 'json',
url: 'Component_getTextContentHistoryRevisionDictListAsJSON', url: 'ComponentMixin_getTextContentHistoryRevisionDictListAsJSON',
success: successHandler}); success: successHandler});
} }
......
erp5_crm erp5_crm
erp5_dms erp5_dms
\ No newline at end of file erp5_trade
\ No newline at end of file
erp5_base
erp5_interfaces erp5_interfaces
\ No newline at end of file
...@@ -37,81 +37,85 @@ from Products.ERP5.mixin.variated import VariatedMixin ...@@ -37,81 +37,85 @@ from Products.ERP5.mixin.variated import VariatedMixin
class Consumption(XMLObject, XMLMatrix, VariatedMixin): class Consumption(XMLObject, XMLMatrix, VariatedMixin):
""" """
A matrix which provides default quantities A matrix which provides default quantities
for a given quantity for a given quantity
""" """
meta_type = 'ERP5 Consumption' meta_type = 'ERP5 Consumption'
portal_type = 'Consumption' portal_type = 'Consumption'
# Declarative security # Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties # Declarative properties
property_sheets = ( PropertySheet.Base property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject , PropertySheet.XMLObject
, PropertySheet.CategoryCore , PropertySheet.CategoryCore
, PropertySheet.DublinCore , PropertySheet.DublinCore
, PropertySheet.VariationRange , PropertySheet.VariationRange
) )
security.declareProtected(Permissions.ModifyPortalContent, security.declareProtected(Permissions.ModifyPortalContent,
'_setVariationCategoryList') '_setVariationCategoryList')
def _setVariationCategoryList(self,value): def _setVariationCategoryList(self, value, base_category_list=()):
""" """
Set consumption variation category list. Set consumption variation category list.
Set matrix cell range. Set matrix cell range.
""" """
self._setCategoryMembership(self.getVariationRangeBaseCategoryList(), self._setCategoryMembership(self.getVariationRangeBaseCategoryList(),
value, base=1) value, base=1)
# XXX Must use in futur this method, but it failed today # XXX Must use in futur this method, but it failed today
#VariatedMixin._setVariationCategoryList(self, value) #VariatedMixin._setVariationCategoryList(self, value)
# XXX FIXME: Use a interaction workflow instead # XXX FIXME: Use a interaction workflow instead
# Kept for compatibility. # Kept for compatibility.
self.updateCellRange(base_id='quantity') self.updateCellRange(base_id='quantity')
security.declareProtected(Permissions.ModifyPortalContent, security.declareProtected(Permissions.ModifyPortalContent,
'setVariationCategoryList') 'setVariationCategoryList')
def setVariationCategoryList(self,value): def setVariationCategoryList(self, value, base_category_list=()):
""" """
Set consumption variation category list. Set consumption variation category list.
Reindex Object. Reindex Object.
""" """
self._setVariationCategoryList(value) self._setVariationCategoryList(value)
self.reindexObject() self.reindexObject()
security.declareProtected(Permissions.ModifyPortalContent, security.declareProtected(Permissions.ModifyPortalContent,
'getVariationRangeBaseCategoryItemList') 'getVariationRangeBaseCategoryItemList')
def getVariationRangeBaseCategoryItemList(self): def getVariationRangeBaseCategoryItemList(
""" self,
Return range of base variation item base=1,
Left display display_id='getTitle',
""" current_category=None):
# XXX get TitleOrId """
return map( lambda x: (x,x) , self.getVariationRangeBaseCategoryList() ) Return range of base variation item
Left display
"""
# XXX get TitleOrId
return [(x, x) for x in self.getVariationRangeBaseCategoryList()]
security.declareProtected(Permissions.ModifyPortalContent, security.declareProtected(Permissions.ModifyPortalContent,
'getQuantityRatio') 'getQuantityRatio')
def getQuantityRatio(self, variation_category_line, def getQuantityRatio(self, variation_category_line,
variation_category_column): variation_category_column):
""" """
Return quantity ratio for a virtual cell. Return quantity ratio for a virtual cell.
Return None if not result can be return. Return None if not result can be return.
""" """
cell_quantity_ratio_list = [] cell_quantity_ratio_list = []
for variation_category in (variation_category_line, for variation_category in (variation_category_line,
variation_category_column): variation_category_column):
cell = self.getCell(variation_category, base_id='quantity') cell = self.getCell(variation_category, base_id='quantity')
if cell is None: if cell is None:
return None
else:
cell_quantity_ratio = cell.getProperty('quantity')
if cell_quantity_ratio in [None, 0, '']:
return None return None
else: else:
cell_quantity_ratio = cell.getProperty('quantity') cell_quantity_ratio_list.append( cell_quantity_ratio )
if cell_quantity_ratio in [None, 0, '']:
return None
else:
cell_quantity_ratio_list.append( cell_quantity_ratio )
return cell_quantity_ratio_list[1] / cell_quantity_ratio_list[0] return cell_quantity_ratio_list[1] / cell_quantity_ratio_list[0]
...@@ -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>Consumption</string> </value> <value> <string>Consumption</string> </value>
...@@ -14,6 +20,12 @@ ...@@ -14,6 +20,12 @@
<key> <string>default_source_reference</string> </key> <key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.Document.Consumption</string> </value> <value> <string>Products.ERP5.Document.Consumption</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>document.erp5.Consumption</string> </value> <value> <string>document.erp5.Consumption</string> </value>
...@@ -37,47 +49,7 @@ ...@@ -37,47 +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: 40, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 45, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 46, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 49, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 50, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 53, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 60, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 62, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 63, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 67, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 73, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 75, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 77, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 78, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 82, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 83, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 85, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 87, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 88, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 93, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 95, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 97, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 99, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:103, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:105, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:107, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:108, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:109, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:110, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:111, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:112, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:113, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:114, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:115, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:117, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 62, 4: Arguments number differs from overridden \'_setVariationCategoryList\' method (arguments-differ)</string>
<string>W: 77, 4: Arguments number differs from overridden \'setVariationCategoryList\' method (arguments-differ)</string>
<string>W: 87, 4: Arguments number differs from overridden \'getVariationRangeBaseCategoryItemList\' method (arguments-differ)</string>
<string>W: 93, 13: map/filter on lambda could be replaced by comprehension (deprecated-lambda)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
...@@ -87,13 +59,28 @@ ...@@ -87,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>
...@@ -106,7 +93,7 @@ ...@@ -106,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>
...@@ -115,7 +102,7 @@ ...@@ -115,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>
......
...@@ -227,6 +227,8 @@ ...@@ -227,6 +227,8 @@
<string>matrixbox_for_max_order_quantity</string> <string>matrixbox_for_max_order_quantity</string>
<string>my_view_mode_target_delivery</string> <string>my_view_mode_target_delivery</string>
<string>my_base_price_per_slice</string> <string>my_base_price_per_slice</string>
<string>my_report_mode_listbox_variation_category_item_list</string>
<string>my_view_mode_read_only_title</string>
</list> </list>
</value> </value>
</item> </item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>default</string>
<string>editable</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_report_mode_listbox_variation_category_item_list</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_lines_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Variation Category Items</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: [x[0] for x in cell.getVariationCategoryItemList()]</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>editable</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_view_mode_read_only_title</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_view_mode_title</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
</item> </item>
<item> <item>
<key> <string>form_id</string> </key> <key> <string>form_id</string> </key>
<value> <string>Base_viewTradeFieldLibrary</string> </value> <value> <string>Base_viewPDMFieldLibrary</string> </value>
</item> </item>
<item> <item>
<key> <string>target</string> </key> <key> <string>target</string> </key>
......
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
</item> </item>
<item> <item>
<key> <string>form_id</string> </key> <key> <string>form_id</string> </key>
<value> <string>Base_viewTradeFieldLibrary</string> </value> <value> <string>Base_viewPDMFieldLibrary</string> </value>
</item> </item>
<item> <item>
<key> <string>target</string> </key> <key> <string>target</string> </key>
......
...@@ -191,7 +191,7 @@ ...@@ -191,7 +191,7 @@
</item> </item>
<item> <item>
<key> <string>form_id</string> </key> <key> <string>form_id</string> </key>
<value> <string>Base_viewTradeFieldLibrary</string> </value> <value> <string>Base_viewFieldLibrary</string> </value>
</item> </item>
<item> <item>
<key> <string>list_action</string> </key> <key> <string>list_action</string> </key>
......
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
</item> </item>
<item> <item>
<key> <string>form_id</string> </key> <key> <string>form_id</string> </key>
<value> <string>Base_viewTradeFieldLibrary</string> </value> <value> <string>Base_viewPDMFieldLibrary</string> </value>
</item> </item>
<item> <item>
<key> <string>target</string> </key> <key> <string>target</string> </key>
......
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
</item> </item>
<item> <item>
<key> <string>form_id</string> </key> <key> <string>form_id</string> </key>
<value> <string>Base_viewTradeFieldLibrary</string> </value> <value> <string>Base_viewPDMFieldLibrary</string> </value>
</item> </item>
<item> <item>
<key> <string>target</string> </key> <key> <string>target</string> </key>
......
document.erp5.Consumption
\ No newline at end of file
...@@ -87,6 +87,9 @@ ...@@ -87,6 +87,9 @@
<portal_type id="Inventory Report Module"> <portal_type id="Inventory Report Module">
<item>Inventory Report</item> <item>Inventory Report</item>
</portal_type> </portal_type>
<portal_type id="Order Builder">
<item>First Causality Movement Group</item>
</portal_type>
<portal_type id="Order Root Simulation Rule"> <portal_type id="Order Root Simulation Rule">
<item>Category Membership Divergence Tester</item> <item>Category Membership Divergence Tester</item>
<item>DateTime Divergence Tester</item> <item>DateTime Divergence Tester</item>
......
...@@ -42,6 +42,7 @@ Inventory Module | Inventory ...@@ -42,6 +42,7 @@ Inventory Module | Inventory
Inventory Report Module | Inventory Report Inventory Report Module | Inventory Report
Inventory Report | Inventory Report Line Inventory Report | Inventory Report Line
Inventory | Inventory Line Inventory | Inventory Line
Order Builder | First Causality Movement Group
Order Root Simulation Rule | Category Membership Divergence Tester Order Root Simulation Rule | Category Membership Divergence Tester
Order Root Simulation Rule | DateTime Divergence Tester Order Root Simulation Rule | DateTime Divergence Tester
Order Root Simulation Rule | Float Divergence Tester Order Root Simulation Rule | Float Divergence Tester
......
import json
from Products.ERP5Type.Utils import checkPythonSourceCode
def checkPythonSourceCodeAsJSON(self, data, REQUEST=None):
"""
Check Python source suitable for Source Code Editor and return a JSON object
"""
# XXX data is encoded as json, because jQuery serialize lists as []
if isinstance(data, basestring):
data = json.loads(data)
# data contains the code, the bound names and the script params. From this
# we reconstruct a function that can be checked
def indent(text):
return ''.join((" " + line) for line in text.splitlines(True))
is_python_script = 'bound_names' in data
if is_python_script:
signature_parts = data['bound_names']
if data['params']:
signature_parts += [data['params']]
signature = ", ".join(signature_parts)
function_name = "function_name"
body = "def %s(%s):\n%s" % (function_name,
signature,
indent(data['code']) or " pass")
else:
body = data['code']
message_list = checkPythonSourceCode(body.encode('utf8'), data.get('portal_type'))
for message_dict in message_list:
if is_python_script:
message_dict['row'] = message_dict['row'] - 2
else:
message_dict['row'] = message_dict['row'] - 1
if message_dict['type'] in ('E', 'F'):
message_dict['type'] = 'error'
else:
message_dict['type'] = 'warning'
if REQUEST is not None:
REQUEST.RESPONSE.setHeader('content-type', 'application/json')
return json.dumps(dict(annotations=message_list))
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Extension Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>PythonCodeUtils</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>extension.erp5.PythonCodeUtils</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Extension Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</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>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<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>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Component_getTextContentHistoryRevisionDictListAsJSON</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
</item> </item>
<item> <item>
<key> <string>_module</string> </key> <key> <string>_module</string> </key>
<value> <string>ERP5Administration</string> </value> <value> <string>PythonCodeUtils</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -3,4 +3,5 @@ extension.erp5.InventoryBrain ...@@ -3,4 +3,5 @@ extension.erp5.InventoryBrain
extension.erp5.SearchUtility extension.erp5.SearchUtility
extension.erp5.StandardSecurity extension.erp5.StandardSecurity
extension.erp5.ZODBHistory extension.erp5.ZODBHistory
extension.erp5.FolderWorkflowActionUtils extension.erp5.FolderWorkflowActionUtils
\ No newline at end of file extension.erp5.PythonCodeUtils
\ No newline at end of file
...@@ -180,6 +180,7 @@ ignored_skin_id_set = { ...@@ -180,6 +180,7 @@ ignored_skin_id_set = {
'SaleInvoiceTransaction_selectTaskReportMovement', 'SaleInvoiceTransaction_selectTaskReportMovement',
'TaskListOverviewGadget_setPreferences', 'TaskListOverviewGadget_setPreferences',
'TaskListsGadgetListbox_getLineCss', 'TaskListsGadgetListbox_getLineCss',
'InventoryModule_reindexMovementList',
} }
# Generic method to check consistency of a skin item # Generic method to check consistency of a skin item
......
...@@ -43,13 +43,11 @@ class CodingStyleTest(CodingStyleTestCase, testXHTML.TestXHTMLMixin): ...@@ -43,13 +43,11 @@ class CodingStyleTest(CodingStyleTestCase, testXHTML.TestXHTMLMixin):
""" """
def getBusinessTemplateList(self): def getBusinessTemplateList(self):
# install erp5_administration to check with tools from erp5_administration # install erp5_upgrader for CodingStyleTestCase.test_run_upgrader
# and erp5_upgrader for CodingStyleTestCase.test_run_upgrader
# XXX also install erp5_full_text_myisam_catalog to workaround missing test # XXX also install erp5_full_text_myisam_catalog to workaround missing test
# dependencies and the fact that test dependencies are not checked # dependencies and the fact that test dependencies are not checked
# recursively. # recursively.
return ( return (
'erp5_administration',
'erp5_upgrader', 'erp5_upgrader',
'erp5_full_text_myisam_catalog', 'erp5_full_text_myisam_catalog',
self.tested_business_template) self.tested_business_template)
......
...@@ -92,11 +92,8 @@ class CodingStyleTestCase(ERP5TypeTestCase): ...@@ -92,11 +92,8 @@ class CodingStyleTestCase(ERP5TypeTestCase):
def test_PythonSourceCode(self): def test_PythonSourceCode(self):
"""test python script from the tested business templates. """test python script from the tested business templates.
reuses BusinessTemplate_getPythonSourceCodeMessageList from erp5_administration reuses BusinessTemplate_getPythonSourceCodeMessageList
""" """
if 'erp5_administration' not in self.getBusinessTemplateList():
self.skipTest('erp5_administration needs be installed to check python source code')
self.maxDiff = None self.maxDiff = None
for business_template in self.portal.portal_templates.contentValues(): for business_template in self.portal.portal_templates.contentValues():
if business_template.getTitle() in self.getTestedBusinessTemplateList(): if business_template.getTitle() in self.getTestedBusinessTemplateList():
......
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