[Sugar-devel] web-activity: env.getEnvironment dependency with Python code

Daniel Narvaez dwnarvaez at gmail.com
Wed Nov 27 04:53:29 EST 2013


This makes me wonder if the current approach is actually racy by the way...
I'm not sure the window object is guaranteed to be ready even on the
load_finished event. Network and javascript context might be completely
independent from this point of view (they are in separate processes after
all).

I feel the best approach here is the webkit extension really, even if it
requires a little bit of C code.

On Wednesday, 27 November 2013, Daniel Narvaez wrote:

> Hi,
>
> did you try to implement it and see if it works? I probably tried this
> when I first implemented getEnvironment but I might have done it wrong or
> something. My worry is that the javascript context might not be ready yet
> at that time, so either the python js code would fail or affect the old
> view.
>
> By the way, if you are determined to solve this and the loaded_started
> approach doesn't work, I know it would be possible to make it work using
> this
>
> http://webkitgtk.org/reference/webkit2gtk/unstable/WebKitScriptWorld.html
>
> It runs in the web process, so it tells you exactly when a new window
> object is created. Though using that API requires an extension written in C
> :/ If despite that you are interested in working on that I can give you
> some more pointers.
>
> On Wednesday, 27 November 2013, Rogelio Mita wrote:
>
>> I noticed existence of a WebKitWebView event which is emitted before what
>> any resource be loaded, called webkit_loaded_started<http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#WEBKIT-LOAD-STARTED:CAPS>
>>
>>> WEBKIT_LOAD_STARTED: A new load request has been made. No data has been
>>> received yet, empty structures have been allocated to perform the load; the
>>> load may still fail due to transport issues such as not being able to
>>> resolve a name, or connect to a port.
>>
>> I did a concept proof on sugar-toolkit-gtk3 to show this behaviour and
>> the result was:
>>
>> [image: Imágenes integradas 1]
>>
>> I think that this behaviour can solve the issue with env.getEnvironment
>> and your hard dependency with sugar var provided by python code.
>>
>> This log also show how load_event_finished is executed between successive
>> requests, then there is no doubt about the current problem existence.
>>
>> You think this may be a solution?, change the script so that it is now
>> run in this event (load_event_started) and rewrite getEnvironment
>> disregarding the possibility that there is no environment variable provided
>> by the Python code, in others words ever when activity is in sugar mode,
>> window.sugar.environment will be present
>>
>>
>> --
>> Roger
>>
>> Activity Central <http://activitycentral.com/>
>>
>
>
> --
> Daniel Narvaez
>
>

-- 
Daniel Narvaez
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20131127/e8bf856a/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 149292 bytes
Desc: not available
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20131127/e8bf856a/attachment-0001.png>


More information about the Sugar-devel mailing list