Move dictionary from instance to class level
frank at chagford.com
Fri Aug 28 08:06:14 CEST 2009
Dave Angel wrote:
> OK, that makes good sense. And I withdraw any suggestion to use pickling,
> since that could be subject to hacking.
> It now appears that the messages are only incidentally GUI events. And
> that you would be well advised to make every possible event a separate
> message, so that if the server state and the client state get out of
> synch, you can readily check and reject such operations. For example,
> you'd have a message for pressing the SUBMIT button on a particular form,
> but you'd have different message types for other buttons on the same form,
> or for SUBMIT on other forms.
I use the same message type for all SUBMITs, but the body of the message
contains a unique id for each button.
When the server constructs the form, it assigns a unique id to each widget,
and includes this id in the form definition it sends to the client.
Therefore the server and client can unambiguously reference specific
widgets, and there is no real danger of getting out of sync.
More information about the Python-list