2013/11/22 Daniel Narvaez <dwnarv...@gmail.com> > On 22 November 2013 21:20, Rogelio Mita > <rogeliom...@activitycentral.com>wrote: > >> >> 2013/11/22 Daniel Narvaez <dwnarv...@gmail.com> >> >>> Yes the callback is never executed because there is no python >>> notification. And our test succeeds because it doesn't make sure that the >>> callback is called. >> >> >> Ok, I see... >> >> I am watching >> https://github.com/sugarlabs/sugar-toolkit-gtk3/blob/master/src/sugar3/activity/webactivity.py#L89and >> I can see if we are in standalone mode this fragment of code is not >> executed (obvious because the activity is not started from sugar) then we >> don't have *window.suga*r global var, and I think that it is good and >> need be maintained through all cycle (is understood?). >> I mean, if you are in *standalone mode* you should not exist *"global" >> sugar var*, >> > > Yeah I think setting that variable is wrong. I probably know why I did it > but I was just missing something. We should remove that... >
> >> >> and in the client side, the logic for *onStandalone* method *is check >> that sugar var existence*. >> Because I noted the behaviour when *sugar var* don't exists on client >> side, this >> fragment<https://github.com/sugarlabs/sugar-web/blob/master/env.js#L13>creates >> this variable anyway and I do not understand why. >> >> I propose remove this fragment at the moment and make a method >> activity.onStandalone (as was already discussed with Manu, I remember) and >> the logic can be: checks existence of sugar var, make sence? >> > > I think I was the one suggesting to add an isStandalone method. But after > looking into it a bit more I tend tothink it's better to make > getEnvironment pass null to the callback, it should make it easier to write > code that works in both modes. > > About the logic, unfortunately checking window.sugar won't work because we > can't assume window.sugar has been already set when getEnvironment is > called... the python code you linked might be called after getEnvironment > has been called and will erroneously think we are in standalone mode. > you are right. I thought for a moment that this fragment is executed to begging before activity.setup(), I'm still in doubt, are you sure about this? > > That's why I suggested to check if window.location starts with > activity://. It's a bit ugly but it will always work. > Seems to be a good start, if I understand what you say, it would result there is no need to use callbacks in this method, ie: we can return object environment on sugar environment or null in other case, or better yet, ask to Environment model about the mode which is... var environment = env.getEnvironment(), though it sounds redundant... OR! var environment = activity.getEnvironment() sounds better to me, and ask to environment object everything related to him You likes some these ideas? -- Roger Activity Central <http://activitycentral.com/>
_______________________________________________ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel