tests/wxHMI/HMI@wxglade_hmi/hmi.wxg.bak
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 10 Aug 2018 17:45:33 +0300
changeset 2278 a3ac46366b86
parent 1461 954d1f42d42d
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))
[-------------------------------------------------------------]
1461
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
     1
<?xml version="1.0"?>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
     2
<!-- generated by wxGlade HG on Wed Oct 02 23:48:24 2013 -->
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
     3
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
     4
<application path="" name="" class="" option="0" language="python" top_window="wxglade_hmi" encoding="UTF-8" use_gettext="0" overwrite="0" use_new_namespace="1" for_version="2.8" is_template="0" indent_amount="4" indent_symbol="space" source_extension=".cpp" header_extension=".h">
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
     5
    <object class="Class_wxglade_hmi" name="wxglade_hmi" base="EditFrame">
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
     6
        <style>wxCAPTION|wxCLOSE_BOX|wxMINIMIZE_BOX|wxMAXIMIZE|wxMAXIMIZE_BOX|wxSYSTEM_MENU|wxRESIZE_BORDER|wxCLIP_CHILDREN</style>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
     7
        <title>frame_1</title>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
     8
        <object class="wxFlexGridSizer" name="grid_sizer_1" base="EditFlexGridSizer">
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
     9
            <hgap>0</hgap>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    10
            <growable_rows>0</growable_rows>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    11
            <rows>1</rows>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    12
            <growable_cols>0</growable_cols>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    13
            <cols>2</cols>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    14
            <vgap>0</vgap>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    15
            <object class="sizeritem">
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    16
                <flag>wxEXPAND</flag>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    17
                <border>0</border>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    18
                <option>1</option>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    19
                <object class="ThreeDee" name="window_1" base="CustomWidget">
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    20
                    <arguments>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    21
                        <argument>$parent</argument>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    22
                        <argument>$id</argument>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    23
                    </arguments>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    24
                    <size>400,400</size>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    25
                </object>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    26
            </object>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    27
            <object class="sizeritem">
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    28
                <flag>wxEXPAND</flag>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    29
                <border>0</border>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    30
                <option>1</option>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    31
                <object class="wxFlexGridSizer" name="sizer_1" base="EditFlexGridSizer">
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    32
                    <hgap>0</hgap>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    33
                    <rows>2</rows>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    34
                    <cols>1</cols>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    35
                    <vgap>0</vgap>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    36
                    <object class="sizeritem">
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    37
                        <flag>wxEXPAND</flag>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    38
                        <border>0</border>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    39
                        <option>1</option>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    40
                        <object class="wxBoxSizer" name="sizer_2" base="EditBoxSizer">
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    41
                            <orient>wxVERTICAL</orient>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    42
                            <object class="sizerslot" />
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    43
                            <object class="sizerslot" />
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    44
                            <object class="sizerslot" />
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    45
                            <object class="sizerslot" />
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    46
                        </object>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    47
                    </object>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    48
                    <object class="sizeritem">
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    49
                        <flag>wxEXPAND</flag>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    50
                        <border>0</border>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    51
                        <option>1</option>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    52
                        <object class="wxGridSizer" name="sizer_3" base="EditGridSizer">
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    53
                            <hgap>0</hgap>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    54
                            <rows>4</rows>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    55
                            <cols>2</cols>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    56
                            <vgap>0</vgap>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    57
                            <object class="sizerslot" />
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    58
                            <object class="sizerslot" />
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    59
                            <object class="sizerslot" />
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    60
                            <object class="sizerslot" />
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    61
                            <object class="sizerslot" />
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    62
                            <object class="sizerslot" />
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    63
                            <object class="sizerslot" />
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    64
                            <object class="sizerslot" />
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    65
                        </object>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    66
                    </object>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    67
                </object>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    68
            </object>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    69
        </object>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    70
    </object>
954d1f42d42d Added wxHMI test
Edouard Tisserant
parents:
diff changeset
    71
</application>