Going on, but first some clarification...
[email protected] (Dallas Johnston)
| Newsgroups | gmane.comp.python.anygui.devel |
|---|---|
| Message-ID | <[email protected]> |
It seems that we are all, more or less, explaining the same beast here, with regard to models, only we are having trouble invisioning each other's perspectives. This is an all too common error =). Imagine placing three people in three seperate rooms, partitioned off with three curtains that join in the middle to form a pie like construct. Then imagine that we place some large beast in the center, under the curtain, that none of the observers have ever seen before. Note that no one person can see more than a 120 degree slice of the animal. Now have these people venture as to what this animal is, stateting the details of how and why they made their conclusion. The image you will probably have in the end, as a sum of all the conclusions, is probably something that one might only see in science fiction, horror movies o~) ... So, I would like to try and explain what it is that I have done in the simplest terms, all technobabble aside. 1) 'A model is only a glorified value,' nothing more, nothing less. Thus, a model serves its greatest purpose when observed by some other entity for change. Of course, models can provide some measure of sophistication, however whatever the magnitude of complexity it may encompass, it will always remain a 'glorified value' to the outside world. 2) The semantics of the actual initialisation and assignment is really only peripheral to the issue at hand, and largely subject to personal bias. It is better that we just get something that works for now, and modify that as we all see fit to represent the greater consensus. For now, what follows is what has been done, and it is by no means permanent. model initialisation in the proxy: >>> proxy.install/remove<Property>Model(<SomeModel>(...)) - This was chosen so that model instillation removal can be logically separated for the benefit of the uninitiated. a) model.value assigment: >>> proxy.<ModelAsProperty> = SomeValue - This avoids the modify() goo. b) model assignment: >>> foo = proxy.<ModelAsProperty> - foo at this point holds a reference to the Model. c) user manupulation of the model via the GUI: # user inputs some data # model is updated accordingly via the call to Proxy.push by the wrapper d) model evaluation: >>> print foo + proxy.<ModelAsProperty>[1:] - At this point, the relative method will be called on the Model from the python runtime Now, what is happening under the covers? This will be discussed next. When a Model is installed (a), the Model is inserted into a dictionary of installed models with the property name as its key. Model.install(proxy, propertyName) is also called on the model so as to allow it to call proxy.push when the model has been modified in-place, i.e. through slice assignment per above. When a Model has been assigned a value (b), Proxy determines if the property assignment involves an installed model and thus calls Model.setValue(..) with the value obtained during the call to rawSet in Attribs, which replaced the Model in self.state. Proxy then assignes the model back into state[prop] before the call onto Wrapper.push(state) occurs. Model also makes a call onto send(self, ...) for all its observers to be notified of the change. In the case that the user has changed some property of a widget via GUI interaction (c), a call to Proxy.push can be called to update the model. It is also possible for the Wrapper to just assign values, this updating the model the conventional way (b). At the end of the day (or procedure, as it were =P), the latter results in a call to Proxy.push aswell. When a Model is evaluated (d), Proxy returns a reference to the Model and the appropriate call is made onto the Model method that corresponds directly to the context of invocation. This str(Proxy.<ModelAsProperty>) will result in a direct call to Model.__str__(). Now as it stands, this functionality has been 99% implemented, with that last 1% consisting of trivial bugs. Are we not wanting to try this code out? As Magnus has already given the OK, I will commit it. However, lets get things going forward =). --Dallas __________________________________________________________________ The NEW Netscape 7.0 browser is now available. Upgrade now! http://channels.netscape.com/ns/browsers/download.jsp Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/ ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf