Re: LeoWapp will use WebSockets and Python 3

2018-10-30 Thread Terry Brown
On Tue, 30 Oct 2018 12:16:34 -0500
"Edward K. Ream"  wrote:

> I've gotten the first few Flexx examples working.  The widgets look
> ugly, but perhaps that will not be an issue in the long run...

I'm not sure how that will play out, for example can you integrate
Flexx with other layers like Bootstrap?

It can embed editors like Ace:
https://flexx.readthedocs.io/en/stable/examples/editor_ace_src.html#editor-ace-py

and use frameworks like d3:
https://flexx.readthedocs.io/en/stable/examples/d3_collision_src.html#d3-collision-py

Flexx's tree is fairly basic, no keyboard nav. etc., if I were
attempting what you're attempting I'd look at using
http://www.inspire-tree.com/ from Flexx - Offray pointed out Inspire Tree 
recently.

I'm not saying that's an easy way to go, but it might give you a head
start vs. adding features to Flexx's tree.

Cheers -Terry

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: LeoWapp will use WebSockets and Python 3

2018-10-30 Thread Edward K. Ream
On Tue, Oct 30, 2018 at 12:14 PM Terry Brown wrote:

> What framework do you prefer?
>
...

> Flexx uses web-sockets by default / exclusively, so it's probably going
> to be the most solid there.
>

That seems important.

Flexx's approach is idiosyncratic enough that you're probably stuck
> with it if you use it (it translates Python to Javascript :-) but there
> might be options which let you separate the transport layer.  Certainly
> this would be the case if you were using regular AJAX, I'm less
> familiar with options for websockets.
>

Not sure what to think about this.

I'm thinking the decision that LeoWapp will use websockets is fine, but
> you won't always see the performance benefits of websockets over AJAX.
>

Performance is a secondary consideration. Imo, websockets is the only thing
that could possibly work in a natural manner.

Before I knew of websockets I considered several alternatives using ajax.
All of them seem like Rube Goldberg machines.  I say this because Leo is
definitely not your typical web app.  If we are to bring *full* Leo to the
browser, then we have to allow Ctrl-b and @button scripts.  That is, we
must have true, two-way, communication between Leo's core and the browser,
with browser gui code standing in the middle.

Leo's scripts (and Leo's core) know nothing about which gui is in effect,
but they may well do things that affect the gui.  Without websockets we
will probably have to kludge up some kind of standard interaction between
scripts, Leo and the browser.  With websockets we can just let interactions
happen when they happen.

I'm not being overly clear here, but I think the Leo's gui layer would be
straightforward with web sockets and difficult or impossible without.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: LeoWapp will use WebSockets and Python 3

2018-10-30 Thread Edward K. Ream
On Tue, Oct 30, 2018 at 12:11 PM Offray Vladimir Luna Cárdenas wrote:

> From my Python times, I liked a lot web2py[1] as a full stack python based
> but easy and self-contained web framework. Bottle and Flask would be my
> alternatives for minimal web frameworks.
>
> [1] http://web2py.com/
>
Thanks for this.  I'll add web2py and Bottle to the list.

I've gotten the first few Flexx examples working.  The widgets look ugly,
but perhaps that will not be an issue in the long run...

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: LeoWapp will use WebSockets and Python 3

2018-10-30 Thread Terry Brown
On Tue, 30 Oct 2018 11:50:12 -0500
"Edward K. Ream"  wrote:

> On Tue, Oct 30, 2018 at 11:07 AM Terry Brown 
> wrote:
> 
> I do wonder if it's necessary to include development of a websockets
> > layer in LeoWapp.  Maintenance burden, complexity, all that.
> >
> > Flexx is a Python framework that uses websockets, there are probably
> > others.
> >
> > Also there a lots of web app. frameworks (Flask, Django, etc.) which
> > don't use websockets by default (they use regular AJAX), but can.
> 
> That welcome news. I agree we should use the highest level tools
> available.
> 
> I'll study Flexx, Flask and Django next.  I had no idea they could use
> websockets.
> 
> What framework do you prefer?

They're all very different.  I've used Django quite a bit in the past,
and would again for large web based applications.  It handles user
logins, rights management, templates, database binding and updating,
form generation, etc. etc.  Probably not the right weight for LeoWapp.
I don't know what it's like for web-sockets, "Django Channels" use
web-sockets, that's all I know.

Haven't used Flask, just fiddled with tutorial.  No idea if its
websocket support is very mature / well integrated.

Am playing with Flexx experimenting with visualizing multiple graphs,
thought I'd mentioned that although not seeing the post now.

Flexx uses web-sockets by default / exclusively, so it's probably going
to be the most solid there.

Flexx's approach is idiosyncratic enough that you're probably stuck
with it if you use it (it translates Python to Javascript :-) but there
might be options which let you separate the transport layer.  Certainly
this would be the case if you were using regular AJAX, I'm less
familiar with options for websockets.

I'm thinking the decision that LeoWapp will use websockets is fine, but
you won't always see the performance benefits of websockets over AJAX.
On a local machine AJAX should be fast enough, seeing the "network" is
basically in memory, and over remote links I suspect (not sure) that
you'll need good low latency connectivity or the network will be the
bottleneck, not the transport protocol.  Don't want to dissuade you
from websockets, just that AJAX is more common and therefore easier for
Google to answer random questions etc. etc.

Cheers -Terry

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: LeoWapp will use WebSockets and Python 3

2018-10-30 Thread Offray Vladimir Luna Cárdenas

On 10/30/18 11:50 AM, Edward K. Ream wrote:
> On Tue, Oct 30, 2018 at 11:07 AM Terry Brown  > wrote:
>
> I do wonder if it's necessary to include development of a websockets
> layer in LeoWapp.  Maintenance burden, complexity, all that.
>
> Flexx is a Python framework that uses websockets, there are probably
> others.
>
> Also there a lots of web app. frameworks (Flask, Django, etc.) which
> don't use websockets by default (they use regular AJAX), but can.
>
>
> That welcome news. I agree we should use the highest level tools
> available.
>
> I'll study Flexx, Flask and Django next.  I had no idea they could use
> websockets.
>
> What framework do you prefer?
>
>From my Python times, I liked a lot web2py[1] as a full stack python
based but easy and self-contained web framework. Bottle and Flask would
be my alternatives for minimal web frameworks.

[1] http://web2py.com/

Cheers,

Offray

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: LeoWapp will use WebSockets and Python 3

2018-10-30 Thread Edward K. Ream
On Tue, Oct 30, 2018 at 11:07 AM Terry Brown  wrote:

I do wonder if it's necessary to include development of a websockets
> layer in LeoWapp.  Maintenance burden, complexity, all that.
>
> Flexx is a Python framework that uses websockets, there are probably
> others.
>
> Also there a lots of web app. frameworks (Flask, Django, etc.) which
> don't use websockets by default (they use regular AJAX), but can.
>

That welcome news. I agree we should use the highest level tools available.

I'll study Flexx, Flask and Django next.  I had no idea they could use
websockets.

What framework do you prefer?

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: LeoWapp will use WebSockets and Python 3

2018-10-30 Thread Terry Brown
On Tue, 30 Oct 2018 08:51:18 -0700 (PDT)
"Edward K. Ream"  wrote:

> On Tuesday, October 30, 2018 at 5:54:39 AM UTC-5, Edward K. Ream
> wrote:
> 
> It's troubling to disable security checks, even temporarily. I'm a
> bit 
> > surprised that such matters weren't mentioned in the websockets 
> > documentation
> > .
> 
> The left-hand panel contains links to the full documentation,
> including security.  It's time to study...

I do wonder if it's necessary to include development of a websockets
layer in LeoWapp.  Maintenance burden, complexity, all that.

Flexx is a Python framework that uses websockets, there are probably
others.

Also there a lots of web app. frameworks (Flask, Django, etc.) which
don't use websockets by default (they use regular AJAX), but can.

Cheers -Terry

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: LeoWapp will use WebSockets and Python 3

2018-10-30 Thread Edward K. Ream
On Tuesday, October 30, 2018 at 5:54:39 AM UTC-5, Edward K. Ream wrote:

It's troubling to disable security checks, even temporarily. I'm a bit 
> surprised that such matters weren't mentioned in the websockets 
> documentation .
>

The left-hand panel contains links to the full documentation, including 
security.  It's time to study...

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: LeoWapp will use WebSockets and Python 3

2018-10-30 Thread Edward K. Ream
On Monday, October 29, 2018 at 11:11:17 AM UTC-5, Edward K. Ream wrote:

The next step will be to look at using a javascript client in the browser.
>

On Windows and Mozilla, the browser-based example 
 
does work,  provided that I temporarily disabled noscript's security checks 
for file:/// urls .  Without this 
exception, noscript munges the page and the Mozilla debugger console shows:

Content Security Policy: The page’s settings blocked the loading of a 
resource at inline (“script-src”).

When I close the web page, the demo server throws this exception, but 
continues serving:

Traceback (most recent call last):
  File "c:\Anaconda3\lib\site-packages\websockets\server.py", line 152, in 
handler
yield from self.ws_handler(self, path)
  File "websockets_demo_server.py", line 15, in time
await websocket.send(now)
  File "c:\Anaconda3\lib\site-packages\websockets\protocol.py", line 361, in 
send
yield from self.ensure_open()
  File "c:\Anaconda3\lib\site-packages\websockets\protocol.py", line 501, in 
ensure_open
self.close_code, self.close_reason) from self.transfer_data_exc
websockets.exceptions.ConnectionClosed: WebSocket connection is closed: 
code = 1001 (going away), no reason

This is a bit off-putting, but apparently all is working as it should.

Catching ConnectionClosed changes the noise, but might not be the proper 
solution.

*Summary*

It's troubling to disable security checks, even temporarily. I'm a bit 
surprised that such matters weren't mentioned in the websockets 
documentation .

I'll contact the author to ask his advice on various matters.

The next step will be to fold the relevant code into leowapp.py.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: LeoWapp will use WebSockets and Python 3

2018-10-29 Thread Edward K. Ream
On Monday, October 29, 2018 at 11:06:38 AM UTC-5, Edward K. Ream wrote:

the client.py and server.py shown here 
> do 
> work...I'll see what happens on Windows.
>

Hurray!  Works just fine on Windows 10.

The next step will be to look at using a javascript client in the browser.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: LeoWapp will use WebSockets and Python 3

2018-10-29 Thread Edward K. Ream
On Mon, Oct 29, 2018 at 9:05 AM Edward K. Ream wrote:

> I have not had any joy with various basic WebSockets examples on Windows.

Some of the basic python-only examples don't seem to do anything on Ubuntu.
Happily, the client.py and server.py shown here
do work.  This
is important progress.  I'll see what happens on Windows shortly.

Googling indicates that firewalls should not typically get in the way.
Indeed, the working examples on Ubuntu use ws://localhost:8765.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: LeoWapp will use WebSockets and Python 3

2018-10-29 Thread Edward K. Ream
On Mon, Oct 29, 2018 at 7:47 AM Terry Brown  wrote:

>
> https://github.com/flexxui/flexx
> provides websocket based Python browser GUI connections.
> John Lunzer pointed it out here:
> https://github.com/leo-editor/leo-editor/issues/338#issuecomment-289618411
>
> I've been using it in my recent (non-Leo) experiments in this area.
>

Thanks for these reminders.  I have not had any joy with various basic
WebSockets examples on Windows.  I'll soon test on Ubuntu.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: LeoWapp will use WebSockets and Python 3

2018-10-29 Thread Terry Brown


https://github.com/flexxui/flexx
provides websocket based Python browser GUI connections.
John Lunzer pointed it out here:
https://github.com/leo-editor/leo-editor/issues/338#issuecomment-289618411

I've been using it in my recent (non-Leo) experiments in this area.

Cheers -Terry

On Mon, 29 Oct 2018 03:55:21 -0700 (PDT)
"Edward K. Ream"  wrote:

> Yesterday I started work in earnest on the leowapp.py plugin.  The
> gui work is complete for now: the web page contains the outline, body
> and log panes and the minibuffer.
> 
> Attempting two-way communication encountered a roadblock.  Putting 
> "require(http)" in a client-side script fails with the console
> message:
> 
> ReferenceError: require is not defined
> 
> We can not use a node.js server in the browser, as explained here 
> 
> .
> 
> With my new insights about sockets, I saw that the proper question is
> *not*:
> 
> Can javascript create *servers *in browsers?
> 
> but instead:
> 
> Can javascript create *sockets *in browsers?
> 
> The answer to this question is an emphatic yes 
> .
>  
> This leads to WebSockets ,
> with this tutorial
> .
> 
> *Summary*
> 
> WebSockets is perfect for LeoWapp: high performance, two-way
> communication, supported by all major browsers.  LeoWapp is essential
> if Leo's browser gui is to have the fine granularity I envisaged in
> the initial design.
> 
> web.py  or requests 
>  might replace the aging,
> ugly, python-side guts of leowapp.py. (The present code barfs on POST
> requests). We shall see. requests is part of the Anaconda distro,
> web.py is not.
> 
> Edward
> 
> P. S. Imo, LeoWapp should *require *Python 3. I see no justification 
> supporting Python 2 in leading-edge web work.  Comments in the 
> documentation for the requests package indicate that there are
> serious problems in attempting to do so.
> 
> EKR
> 

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


LeoWapp will use WebSockets and Python 3

2018-10-29 Thread Edward K. Ream
Yesterday I started work in earnest on the leowapp.py plugin.  The gui work 
is complete for now: the web page contains the outline, body and log panes 
and the minibuffer.

Attempting two-way communication encountered a roadblock.  Putting 
"require(http)" in a client-side script fails with the console message:

ReferenceError: require is not defined

We can not use a node.js server in the browser, as explained here 

.

With my new insights about sockets, I saw that the proper question is *not*:

Can javascript create *servers *in browsers?

but instead:

Can javascript create *sockets *in browsers?

The answer to this question is an emphatic yes 
.
 
This leads to WebSockets , with 
this tutorial .

*Summary*

WebSockets is perfect for LeoWapp: high performance, two-way communication, 
supported by all major browsers.  LeoWapp is essential if Leo's browser gui 
is to have the fine granularity I envisaged in the initial design.

web.py  or requests 
 might replace the aging, ugly, 
python-side guts of leowapp.py. (The present code barfs on POST requests). 
We shall see. requests is part of the Anaconda distro, web.py is not.

Edward

P. S. Imo, LeoWapp should *require *Python 3. I see no justification 
supporting Python 2 in leading-edge web work.  Comments in the 
documentation for the requests package indicate that there are serious 
problems in attempting to do so.

EKR

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.