I have a form where self.item is initialised to a record from a data table using a call to a server module.
Within one of the form’s methods I set self.item again with a call to the same server function, but it doesn’t get updated and instead retains the original value.
If I use a different variable name (e.g. self.test instead of self.item) everything works perfectly ok. Is there some restriction on updating self.item within a form?
Erm, no! self.item
is just a property, whose only “special power” is that it automatically calls self.refresh_data_bindings()
whenever you assign it a new value. The behaviour you describe is most unexpected - can you provide us with sample code (or a sample app to clone)?
1 Like
Well, I’m glad you said that! I was a little surprised myself!!
I’ll see if I can replicate the behaviour in a minimal example app and share that. The one where I’ve actually hit the problem is too large to be a useful example
Am I right in thinking this is now fixed? The sample app works ok now - as long as self.person is declared in init before self.item. If they are declared in the opposite order, it throws an error (which I’ve also seen cropping elsewhere in forms that previously worked ok).
Hi,
Yes, this issue is now fixed; and the behaviour you’re seeing is correct. Thanks for your patience!
(If you set self.item = foo
, it will trigger refresh_data_bindings()
. If one of your data bindings refers to a property that doesn’t exist yet, you’ll get an AttributeError
.)
1 Like