Model redesign?
Magnus Lie Hetland <[email protected]>
| Newsgroups | gmane.comp.python.anygui.devel |
|---|---|
| Message-ID | <[email protected]> |
Just some thoughts based on earlier model discussions... (These are just loose thoughts, so Dallas: Don't panic -- we can probably still use much/most of your code ;) It seems that we're having problems with the attribute-bound-to-model design. An alternative has been proposed with special model registering methods. If we are to drop my MVC design in favour of something else, I'd rather have things be even simpler, and to make Proxies even less coupled with models. So... I'm back to using the event system again (which was my original idea). Let's (for now) ignore the fact that Attrib.set(...) takes Option objects as positional arguments, and get to the specifics of that later. Then my idea works basically as follows: >>> btn = Button() >>> mdl = NumberModel(name='x') >>> link(mdl, btn.set) Here, when mdl is modified, btn.set will be called. To implement the controller part of things, Components can be observable as well: >>> link(btn, 'update', mdl.set) Here, of course, mdl.set will be passed lots of attribute/value pairs, most of which are not interesting at all. One quirk of this approach is that the set method is passed an event object. Either we can define some specific functionality to modify the event objects, or we can make set() accept event objects -- or make it possible for Option objects to restrict its items (i.e. have an items() method) and give Event objects the same functionality, and let the sender restrict what attributes are to be used -- or something... Quite loose stuff as yet, but the basic idea is to simply use link() to link observables and observers, and to drop all other MVC functionality (except including the Model classes as utilities). -- Magnus Lie Hetland Practical Python The Anygui Project http://hetland.org http://ppython.com http://anygui.org ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf