Recorded Python scripts do not handle certain proxy parameters correctly
When recording macros, parameters setting are often (or always?) recorded like, for example
proxy.Foo = VALUE
However, this fails for certain derived proxies with error like
File "$PARAVIEWPATH/lib/python2.7/site-packages/paraview/servermanager.py", line 308, in __setattr__
"to add this attribute.")
AttributeError: Attribute Foo does not exist. This class does not allow addition of new attributes to avoid mistakes due to typos. Use add_attribute() if you really want to add this attribute.
I did a naive research on this. From the online documentation of Proxy,
Instead of::
proxy.GetProperty("Foo").SetElement(0, 1)
proxy.GetProperty("Foo").SetElement(0, 2)
you can do::
proxy.Foo = (1,2)
or
proxy.Foo.SetData((1,2))
or
proxy.Foo[0:2] = (1,2)
This feature is really implemented by updating the class dictionary. It appears to me that this can be manually done by c the _createSetProperty
function. For certain derived proxies , their dictionary might not be updated with the extra parameters, thus calls like proxy.Foo = value
fails.
My solution:
The extra parameters have to be accessed like proxy.SetPropertyWithName('parameter_name', value)
. Or, a better choice might be to populate the dictionary with the extra parameters.
Please note that my understanding of pypython is very preliminary (a few days), thus I might not be understanding the features/solutions correctly. However, this is still a bug, in my opinion.