PDA

View Full Version : question/problem


whise
August 14th, 2007, 02:43 PM
hey im having a problem , i want to do something in the screenlet but only after all the atributes are loaded , how can i do it , i was trying to do it in the __setattr__ , but it doesnt work ok
anyone?

RYX
August 14th, 2007, 02:50 PM
The next version comes with a new "on_init"-handler that gets triggered by the session after all options have been loaded. It does exactly what you need. But I am still busy with the website for a few days, so you have to wait until next weekend ...

You can add it manually. Open session.py and browse to this code (in ScreenletService.__load_instances):if sl:
# set options for the screenlet
print "Set options in " + sl.__name__
#self.__restore_options_from_file (sl, self.path + filename)
self.__restore_options_from_backend(sl, self.path+filename)
sl.enable_saving(True)
# and call init handler (ADD THIS LINE AND THE NEXT LINE TO YOUR CODE!!!!)
sl.on_init()

Then open the __init__.py and add an empty "on_init"-function to the Screenlet-class which just passes and does nothing.

That should give you what you need (and even is compatible with the upcoming changes) ....

:)

whise
August 14th, 2007, 03:34 PM
cool i was actully looking in the code for this but couldnt find anything
thanks