Re: Headcount

Magnus Lie Hetland <[email protected]>
Newsgroups gmane.comp.python.anygui.devel
Message-ID <[email protected]>
Samuele Pedroni <[email protected]>:
[snip]

> Yup, but the problem is that in many backends (all?) widget creation
> is triggered by setContainer so you want to call it even if widget
> is None, but not the other setFoos. So the refactoring is not so
> direct.

Right. My first thought was to introduce yet another cusomisable
mechanism for deciding which setFoos are excempt from the "if None"
guard... But it seems that customisable things like these are
proliferating, and I'm not sure if it's just a groove I can't get out
of ;)

But it is a possibility... I.e.:

  if (not self.mustHaveWidget(attr)) or self.widget is not None:
      # Set the attribute

All getters can be protected, I guess.

And another thing: We could introduce a specific exception for
handling this. I.e. the getter code could raise a NoWidgetException if
we try to get an attribute before there's a widget; the front-end
could ignore that, because the value would be in proxy.state. If we
have something like the DummyWidget that raises this exception on all
attribute accesses, that could be used instead of comparing with None
too... But without much gain, I guess. (The None stuff is simple,
clean, and easy to understand.)

But I would like to avoid having every setter and getter checking for
None -- it's one of the warts of 0.1, IMO.

> regards.

-- 
Magnus Lie Hetland                                  The Anygui Project
http://hetland.org                                  http://anygui.org


-------------------------------------------------------
In remembrance
www.osdn.com/911/
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.