i18n/app.fil
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 10 Aug 2018 17:45:33 +0300
changeset 2278 a3ac46366b86
parent 2186 2ec02f0f9fa9
child 2426 aef7f2ca4e69
permissions -rw-r--r--
Dirty fix for error '_object_has_no_attribute_'getSlave' in EtherCAT extension

traceback:
File "/home/developer/WorkData/PLC/beremiz/beremiz/IDEFrame.py", line 1433, in OnPouSelectedChanged
window.RefreshView()
File "/home/developer/WorkData/PLC/beremiz/beremiz/etherlab/ConfigEditor.py", line 837, in RefreshView
self.RefreshProcessVariables()
File "/home/developer/WorkData/PLC/beremiz/beremiz/etherlab/ConfigEditor.py", line 886, in RefreshProcessVariables
slaves = self.Controler.GetSlaves(**self.CurrentNodesFilter)
File "/home/developer/WorkData/PLC/beremiz/beremiz/etherlab/EthercatMaster.py", line 341, in GetSlaves
for slave in self.Config.getConfig().getSlave():
<type 'exceptions.AttributeError'>:_'lxml.etree._Element'_object_has_no_attribute_'getSlave'

Steps to reproduce problem:

- Add new EtherCAT master
- Add new EthercatNode to the master
- double click on


this is looks like dirty hack to fix strange problem with initial[0]
changing its type after returning from _init_ method to lxml.etree._Element
As a result all methods generated by class factory are lost.

For example, in function initMethod initial[0].__class__ points to
xmlclass.xmlclass.Config. After map(self.append, initial)
self.Config.__class__ is 'xmlclass.xmlclass.Config' as well.
But after returning from initMethod (_init) in CreateElement
self.Config.__class__ has changed to lxml.etree._Element.


I've noticed similar behavior if copy/deepcopy is used for any child
of etree.ElementBase. See simple example below.
[-------------------------------------------------------------]
#!/usr/bin/python

from __future__ import print_function
from lxml import etree
import copy

class DefaultElementClass(etree.ElementBase):
def getLocalTag(self):
return etree.QName(self.tag).localname


def printInformation(x):
print(x, x.__class__, "getLocalTag" in dir(x))


a = DefaultElementClass()
printInformation(a)

#
printInformation(copy.copy(a))
printInformation(copy.deepcopy(a))
[-------------------------------------------------------------]
../canfestival/canfestival.py
../canfestival/SlaveEditor.py
../canfestival/config_utils.py
../canfestival/NetworkEditor.py
../BeremizIDE.py
../dialogs/LDElementDialog.py
../dialogs/ForceVariableDialog.py
../dialogs/SearchInProjectDialog.py
../dialogs/SFCStepDialog.py
../dialogs/SFCStepNameDialog.py
../dialogs/FindInPouDialog.py
../dialogs/SFCDivergenceDialog.py
../dialogs/SFCTransitionDialog.py
../dialogs/DurationEditorDialog.py
../dialogs/PouTransitionDialog.py
../dialogs/FBDVariableDialog.py
../dialogs/BlockPreviewDialog.py
../dialogs/AboutDialog.py
../dialogs/ProjectDialog.py
../dialogs/LDPowerRailDialog.py
../dialogs/ArrayTypeDialog.py
../dialogs/PouNameDialog.py
../dialogs/BrowseLocationsDialog.py
../dialogs/FBDBlockDialog.py
../dialogs/ConnectionDialog.py
../dialogs/BrowseValuesLibraryDialog.py
../dialogs/ActionBlockDialog.py
../dialogs/PouActionDialog.py
../dialogs/DiscoveryDialog.py
../dialogs/PouDialog.py
../graphics/RubberBand.py
../graphics/FBD_Objects.py
../graphics/DebugDataConsumer.py
../graphics/ToolTipProducer.py
../graphics/LD_Objects.py
../graphics/SFC_Objects.py
../graphics/GraphicCommons.py
../connectors/PYRO/__init__.py
../connectors/PYRO/dialog.py
../connectors/__init__.py
../connectors/WAMP/__init__.py
../connectors/WAMP/dialog.py
../targets/Generic/XSD
../targets/XSD_toolchain_makefile
../targets/Xenomai/__init__.py
../targets/Xenomai/XSD
../targets/XSD_toolchain_gcc
../targets/__init__.py
../targets/toolchain_gcc.py
../targets/toolchain_makefile.py
../targets/Linux/XSD
../targets/Win32/XSD
../PLCControler.py
../PLCOpenEditor.py
../py_ext/PythonEditor.py
../py_ext/PythonFileCTNMixin.py
../wxglade_hmi/wxglade_hmi.py
../modbus/modbus.py
../runtime/NevowServer.py
../runtime/WampClient.py
../runtime/PLCObject.py
../runtime/ServicePublisher.py
../ConfigTreeNode.py
../editors/ConfTreeNodeEditor.py
../editors/ResourceEditor.py
../editors/Viewer.py
../editors/LDViewer.py
../editors/DataTypeEditor.py
../editors/IECCodeViewer.py
../editors/TextViewer.py
../editors/ProjectNodeEditor.py
../editors/EditorPanel.py
../editors/DebugViewer.py
../editors/SFCViewer.py
../editors/FileManagementPanel.py
../editors/CodeFileEditor.py
../ProjectController.py
../controls/LocationCellEditor.py
../controls/SearchResultPanel.py
../controls/PouInstanceVariablesPanel.py
../controls/CustomTable.py
../controls/EnhancedStatusBar.py
../controls/LibraryPanel.py
../controls/UriLocationEditor.py
../controls/CustomToolTip.py
../controls/LogViewer.py
../controls/FolderTree.py
../controls/ProjectPropertiesPanel.py
../controls/DebugVariablePanel/DebugVariablePanel.py
../controls/DebugVariablePanel/DebugVariableViewer.py
../controls/DebugVariablePanel/DebugVariableTextViewer.py
../controls/DebugVariablePanel/DebugVariableGraphicViewer.py
../controls/DebugVariablePanel/GraphButton.py
../controls/DebugVariablePanel/DebugVariableItem.py
../controls/TextCtrlAutoComplete.py
../controls/DurationCellEditor.py
../controls/CustomStyledTextCtrl.py
../controls/VariablePanel.py
../controls/CustomGrid.py
../controls/CustomIntCtrl.py
../controls/CustomTree.py
../controls/CustomEditableListBox.py
../CodeFileTreeNode.py
../docutil/dochtml.py
../c_ext/CFileEditor.py
../xmlclass/xsdschema.py
../xmlclass/xmlclass.py
../Beremiz.py
../version.py
../POULibrary.py
../util/MiniTextControler.py
../util/ExceptionHandler.py
../util/misc.py
../util/ProcessLogger.py
../features.py
../svgui/svgui.py
../svgui/svgui_server.py
../svgui/svguilib.py
../plcopen/InstancesPathCollector.py
../plcopen/types_enums.py
../plcopen/InstanceTagnameCollector.py
../plcopen/BlockInstanceCollector.py
../plcopen/iec_std.csv
../plcopen/structures.py
../plcopen/XSLTModelQuery.py
../plcopen/POUVariablesCollector.py
../plcopen/VariableInfoCollector.py
../plcopen/plcopen.py
../plcopen/definitions.py
../IDEFrame.py
../PLCGenerator.py
../Beremiz_service.py
../plcopen/Additional_Function_Blocks.xml
../plcopen/Standard_Function_Blocks.xml