Re: Q: wrappers push/pull and models

"Samuele Pedroni" <[email protected]>
Newsgroups gmane.comp.python.anygui.devel
Message-ID <005501c25a73$83100800$6d94fea9@newmexico>
> Samuele Pedroni wrote:
> >
>
> [scissors of brevity]
>
> > indeed but not messing with vs. keeping them alive through storing are
> > different things. It seems (but maybe I'm wrong) that the current code
needs
> > the latter, which would be complexity "pushed" down in the wrappers again.
>
> Are you concerned with models being GC'd? I would think that if
> a model is used, the application would keep a reference to it,
> so Anygui doesn't need to worry about that.
>

Honestly if I set a property to a model in a component a would aspect the
component to keep it alive. But anyway the point was another and I was
imprecise. The problem:   if the proxy and the wrapper don't keep a reference
to the model and just keep the value or forget about the model how can they
behave properly, i.e. e.g. update the model.

Maybe the code is correct and it is just me missing something. But if I set a
sofar-not-set property to a model it seems that following happens:

model goes in proxy state, model is pushed down to wrapper, wrapper sets model
value (if it can deal with model) into widget and forget about model.

Now if I try to set the property again: first property value is pulled from
wrapper, wrapper get the value from widget (this is the aformen. plain value),
plain value is put in state,  thus any notion of prop being bound to a model is
lost...

The relevant code is:
Attrib __setattr__ calls set that calls rawSet which does:

            old_val = getattr(self, key, None)

that triggers the discussed behavior through Attrib __getattr__ that invokes:

                    self.pull(*(name,))

triggering in Proxy.pull:

        self.wrapper.pull(state)
        self.state.update(state)

now  wrapper.pull knows nothing about models and simply does with state:

      for attr in [k for k in state.keys() if k not in unhandled]:
            state[attr] = lstate[attr]

and then self.state.update(state) kill with the plain value the model living in
self.state, and then we are back to logic in rawSet that nevertheless expects
that old_val could be a model and tries to deal with that:

            try: old_val.removed(self, key)
            except: pass

regards.







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