On Thu, Oct 17, 2013 at 9:27 AM, C Anthony Risinger <[email protected]> wrote:

> On Thu, Oct 17, 2013 at 4:50 AM, Sarvi Shanmugham <[email protected]>wrote:
>
>> Found this
>> http://comments.gmane.org/gmane.linux.laptop.olpc.sugar/39321
>> https://bugzilla.gnome.org/show_bug.cgi?id=641944
>>
>> Which talks about the issue and a change in the gobject API
>>
>
> ah dang, thanks for the link.
>
> i'll have to update the backend then... there wasn't a reason i used the
> set/get methods other than i thought they might be more stable...
>
> if you change:
>
>     def setattr(self, inst, key, attr):
>
>         # hasattr() *specifically* chosen because it calls getattr()
>
>         # internally, possibly setting a proxy object; if True, super()
>         # will then properly setattr() against the proxy or instance.
>
>         if hasattr(inst, key):
>             super(self._type_gi, inst).__setattr__(key, attr)
>
>         else:
>             inst.set_data(key, attr)
>
>             logger.debug('setattr(inst, %r, attr):\n%s', key,
>
>                 pformat([('inst', inst), ('attr', attr)]))
>
>
> ...to:
>
>
>     def setattr(self, inst, key, attr):
>
>         self.getattr(inst, key)
>
>         super(self._type_gi, inst).__setattr__(key, attr)
>
>
> ...i think it will probably work.
>
>
sorry, you need to use hasattr(), in case the attr already existed:


    def setattr(self, inst, key, attr):
        # hasattr() *specifically* chosen because it calls getattr()

        # internally, possibly setting a proxy object; if True, super()
        # will then properly setattr() against the proxy or instance.
        hasattr(inst, key)
        super(self._type_gi, inst).__setattr__(key, attr)


...the "empty" call to hasattr is purely to trigger the creation of a proxy
object, if need be.

-- 

C Anthony

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Pyjs.org Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to