Re: Model redesign?

Magnus Lie Hetland <[email protected]>
Newsgroups gmane.comp.python.anygui.devel
Message-ID <[email protected]>
Samuele Pedroni <[email protected]>:
[snip]
> >   >>> 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:
> 
> but you probably want to be able to bind an
> non-through-ui-modifiable model to more than one components,

Yes? link() can do many-to-many links, so this shouldn't be a problem,
I think (unless I misunderstood you).

> but yes it's workable.
> 
> >   >>> 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.
> 
> update should be generated both on push/pull?

That's one trouble spot: Should pull be triggered by widget change?
The original idea was "no", but that would make controllers
meaningless. So -- should it be optional, possibly triggered by
link()? (I.e. if someone has linked to a button, listening for
'update' events, then pull becomes eager rather than lazy? This could
be done through enableEvent(), which is already implemented in the
event system.)

> the problem is only to avoid that mdl.set triggers btn.set
> recursively,

Riiight... And we can't use mdl.rawSet, since that won't trigger
others... I guess there must be some mechanism in place to break cycle
here. (The easiest would be to check for equality, so that if btn.set
*is* called, it won't do anything.)

> which means extending a bit the functionality of event
> sends or not use events for the above controller functionality...

Right. I mainly like the use of events because it avoids adding
another concept, simply another event type.

> OTOH I'm fine with this approach.

OK -- let's develop it in parallel with the existing approach
(modified as per your/Dallas's suggestions), shall we?

Are there any other MVC fans out there that have any input on this
stuff? (Or non-fans for that matter ;)

> regards.

-- 
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.