[sugar] AttributeErrors

Dan Williams dcbw at redhat.com
Wed Sep 6 10:22:46 EDT 2006


On Wed, 2006-09-06 at 09:34 -0400, Dan Williams wrote:
> On Wed, 2006-09-06 at 00:41 +0200, Marco Pesenti Gritti wrote:
> > Erik Blankinship wrote:
> > > Below is a simple sugar app and the log it creates when run on today's 
> > > build.
> > >
> > > There appears to be a problem with:
> > > [1] AttributeError: 'crop' object has no attribute '_activity_type'
> > > and
> > > [2] AttributeError: 'NoneType' object has no attribute 'get_name'
> > >
> > > If I remove the Presence calls (just the gtk button), I don't get 
> > > these errors.  Any ideas?  Thanks.
> > >
> > >
> > > import gtk
> > >
> > > from sugar.activity.Activity import Activity
> > > from sugar.presence import PresenceService
> > > import logging
> > >
> > > class crop(Activity):
> > >     def __init__(self):
> > >         Activity.__init__(self)
> > >
> > >         button = gtk.Button('Why am I busted?')
> > >         self.add(button)
> > >         button.show()
> > >
> > >         self._ps = PresenceService.get_instance()
> > >         me = self._ps.get_owner()
> > >         name = me.get_name()
> > >         logging.info("I am %s" % name)
> > >         activities = self._ps.get_activities()
> > >         for act in activities:
> > >             logging.info("Activity: %s" % act.get_id())
> > 
> > The presence service owner is initialized asynchronously, so it's 
> > usually None when then presence service has just been instantiated. Dan 
> > should know the details...
> 
> Yeah, there should probably be a way to create at least a skeleton Owner
> object, if nothing else, before the real one is found on the network.
> It seems to be a problem for short-term testing while in the real
> situation the PS would be initialized far before any particular activity
> asks for the owner.

This should be fixed now; but all you really have access to immediately
is the owner's name until the first services provided by the owner (ie,
the chat and presence ones) are resolved.  Eventually you'll likely have
access to the owner's color and such before service resolution too.  So
you shouldn't need to import and/or init sugar.env.

Dan

> Dan
> 
> > An alternative way to get the nick name is to use sugar.env.get_nick_name()
> > 
> > Marco
> 
> _______________________________________________
> Sugar mailing list
> Sugar at laptop.org
> http://mailman.laptop.org/mailman/listinfo/sugar



More information about the Sugar mailing list