sgzwiz / brython

Automatically exported from code.google.com/p/brython
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

import of python files is broken #94

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Here is a sequence of network requests when browsing index.html

GET http://localhost/index.html [HTTP/1.0 200 OK 15ms]
GET http://localhost/brython/brython.js [HTTP/1.0 200 OK 32ms]
GET http://localhost/test_auto.pyb [HTTP/1.0 304 Not Modified 16ms]
GET http://localhost/brython/libs/datetime.js?foo=h41ux0e1 [HTTP/1.0 200 OK 0ms]
GET http://localhost/brython/libs/html.js?foo=mpljof9n [HTTP/1.0 200 OK 16ms]
GET http://localhost/brython/libs/test_builtin.js?foo=mdnibafo [HTTP/1.0 404 
File not found 16ms]
GET http://localhost/test_auto.pyb/test_builtin.pyb?foo=tw4h2r5g [HTTP/1.0 404 
File not found 0ms]
GET http://localhost/test_auto.pyb/test_builtin/__init__.pyb?foo=rrcme5ro 
[HTTP/1.0 404 File not found 16ms]

On can see that the path searched for python import is bad.
http://localhost/test_auto.pyb/test_builtin.pyb should be 
http://localhost/test_builtin.pyb

Original issue reported on code.google.com by d...@famillepinault.fr on 7 Mar 2013 at 8:31

GoogleCodeExporter commented 9 years ago
Nicolas,

I'm not sure I'm following you.  I'm not sure what test_auto.pyb is. and what 
is pyb file?  Do you still get these errors?

Billy

Original comment by billy.earney@gmail.com on 17 Mar 2013 at 8:02

GoogleCodeExporter commented 9 years ago
Hi Billy,

test_auto.pyb is a Brython script. It is has a .pyb extension because the 
server I use is Karrigell. With a .py extension, Karrigell interprets the 
script itself instead of returning the script content to the browser.
For the same reason, I have slightly modified Brython to use .pyb extension for 
import functionnality. The extension to use is an option passed to brython() 
function.
This can be helpfull with all web servers interpreting python scripts.

So, in my case, in test_auto.pyb, I import test_builtin(.pyb). As test_auto.pyb 
is at root, the request should be :
GET http://localhost/test_builtin.pyb?foo=tw4h2r5g
But, it is :
GET http://localhost/test_auto.pyb/test_builtin.pyb?foo=tw4h2r5g

Nicolas

Original comment by d...@famillepinault.fr on 17 Mar 2013 at 8:17

GoogleCodeExporter commented 9 years ago
With revision 725 I get :

[21:37:15,700] GET http://localhost/index.html [HTTP/1.0 200 OK 16ms]
[21:37:15,809] GET http://localhost/brython/brython.js [HTTP/1.0 200 OK 16ms]
[21:37:15,810] GET http://localhost/test_auto.pyb [HTTP/1.0 200 OK 16ms]
[21:37:15,890] GET http://localhost/brython/libs/datetime.js?foo=ya44n4o7 
[HTTP/1.0 200 OK 0ms]
[21:37:15,891] GET http://localhost/brython/libs/html.js?foo=w5vmc2cz [HTTP/1.0 
200 OK 0ms]
[21:37:15,959] GET http://localhost/brython/libs/test_builtin.js?foo=8yy2vdqn 
[HTTP/1.0 404 File not found 0ms]
[21:37:15,959] GET http://localhost/test_auto.pyb/test_builtin.js?foo=mrh8arb8 
[HTTP/1.0 404 File not found 15ms]
[21:37:16,033] GET http://localhost/test_auto.pyb/test_builtin.pyb?foo=fmlficvk 
[HTTP/1.0 404 File not found 0ms]
[21:37:16,034] GET 
http://localhost/test_auto.pyb/test_builtin/test_builtin.js?foo=44j3qnff 
[HTTP/1.0 404 File not found 15ms]
[21:37:16,095] GET 
http://localhost/test_auto.pyb/test_builtin/test_builtin.pyb?foo=qo0po99y 
[HTTP/1.0 404 File not found 0ms]
[21:37:16,065] Error: No module named 'test_builtin'
module '__main__' line 7
import test_builtin @ http://localhost/brython/brython.js:985

So, the problem is still there.
Please, note that I run this test with the simple server.py delivered with 
Brython (Karrigell not involved here).

Nicolas

Original comment by d...@famillepinault.fr on 17 Mar 2013 at 8:42