[Sugar-devel] sugar-web: env.js questions

Daniel Narvaez dwnarvaez at gmail.com
Fri Nov 22 15:44:01 EST 2013


On 22 November 2013 21:20, Rogelio Mita <rogeliomita at activitycentral.com>wrote:

>
> 2013/11/22 Daniel Narvaez <dwnarvaez at 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.

That's why I suggested to check if window.location starts with activity://.
It's a bit ugly but it will always work.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20131122/9ef12c1f/attachment.html>


More information about the Sugar-devel mailing list