Re: Models...

"Samuele Pedroni" <[email protected]>
Newsgroups gmane.comp.python.anygui.devel
Message-ID <04a601c2633a$40203220$6d94fea9@newmexico>
From: Magnus Lie Hetland <[email protected]>
> >>> proxy.attr = value
> >>> proxy.attr is value
> 1
>

OTOH personally I still find to require the idiom

proxy.modify(attr=newval)

to change the value/a model in-place without substituting it awkward.

IMO

proxy.attr = value should change a possible model in-place
OTOH proxy.attr should return the model or the value

and then a model would be installed with

proxy.installModel('attr',Model())

> But, as I said, I think it is better to require the Wrapper to make
> fewer assumptions about the values it receives; e.g. a coordinate will
> be number-like, but not necessarily an int. If the back-end needs an
> int, then the setter should be implemented something like:
>
>   def setX(self, x):
>       if self.widget is not None:
>           self.widget.x = int(x)
> (assuming that we keep the "wrapper is not None"-checking in the
> Wrapper).
>
> The more I think about it, the more I'm convinced that this is the way
> to do it.

the shorter and sweeter to write we can make the wrappers the better,
OTOH they should be copy-and-past-proof, and not too much things should
happen implicitly, so:

[assuming that Dallas saying Proxy manage models means that he has not adopted
passing settesr/getters along to models (?) ]

- having getters to assume that widget is set is OK, if this can be enforced,
because it makes sense in general and does not require special cases
- for setters to check explicitly for widget is sensible, because some need a
widget already there and some trigger widget creation so doing otherwise would
require some magic/implicitness

OTOH apart from implemetation issues at the higher levels, I don't see why it
is bad to assume/enforce that only values are passed to wrappers. I mean
expecting them to convert things is also sensible but makes wrapper code more
convoluted and does it increase clarity?

Unrelated:
*) We should check the issue with setX etc and setGeometry and wrapper
subclasses overriding only setGeometry

*) What is the general opinion about aggregates and models behavior?

Samuele.







-------------------------------------------------------
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.