modular web2py - need help

233 views
Skip to first unread message

Massimo Di Pierro

unread,
Jan 1, 2019, 7:04:33 PM1/1/19
to web2py-users
Based on my new years resolution:

- I posted a new web2py branch called modular.
- I moved template.py into its own folder planning to make its own package
- I refactored validators.py and scheduler.py and moved them into pydal (also branch modula)

Thoughts?
Can you help testing that nothing broke in web2py?

Massimo

黄祥

unread,
Jan 1, 2019, 7:35:53 PM1/1/19
to web2py-users
how to test it ?
$ python -V
Python 3.6.7 :: Anaconda, Inc.

$ git clone
--recursive https://github.com/web2py/web3py
$ python web3py
/start.py

Traceback (most recent call last):
 
File "web3py/start.py", line 8, in <module>
   
from gluon.main import main_wsgi_app, main
 
File "/Users/sugizo/Downloads/learn/web3py/gluon/__init__.py", line 2, in <module>
   
from gluon.url import URL
 
File "/Users/sugizo/Downloads/learn/web3py/gluon/url.py", line 3, in <module>
   
from gluon.utils import web2py_uuid, simple_hash, compare
 
File "/Users/sugizo/Downloads/learn/web3py/gluon/utils.py", line 201
   
except Exception, e:
                   
^
SyntaxError: invalid syntax

best regards,
stifan

Massimo Di Pierro

unread,
Jan 1, 2019, 7:52:39 PM1/1/19
to web2py-users
You are looking at the wrong thing. That is some very old code and it is not going anywhere.

git clone --recursive https://github.com/web2py/web2py.git
git fecth modular
git checkout modular

Massimo

Massimo Di Pierro

unread,
Jan 1, 2019, 7:55:00 PM1/1/19
to web2py-users
Mind I found some errors myself. You want to wait 1-2h so that I fix those first

黄祥

unread,
Jan 2, 2019, 12:18:20 AM1/2/19
to web2py-users
pardon, just following your new year's wish in another thread, think it would be web3py repo
ok, going to try after it's ready

thx n best regards,
stifan

Massimo Di Pierro

unread,
Jan 2, 2019, 1:20:22 AM1/2/19
to web2py-users
It passes all tests now. it is not finished yet but I succeeded in moving scheduler and validators into pydal (they depend on it anyway) and making template stand alone (I found some pre-existing bugs in it). I did not publish the latter to pypi but I will do it later in the week.

I could use some help in:
- move scheduler and validator tests from gluon/tests to gluon/packages/dal/tests
- move (some) template tests to gluon/packages/template/tests
- create a gluon/packages/template/setup.py

sandeep patel

unread,
Jan 2, 2019, 1:36:01 AM1/2/19
to web...@googlegroups.com
I am getting an ImportError error during setup.

Steps:
git checkout modular
python setup.py
Traceback (most recent call last):
  File "setup.py", line 4, in <module>
    from gluon.fileutils import tar, untar, read_file, write_file
  File "D:\TestingWeb3py\web2py\gluon\__init__.py", line 35, in <module>
    from .globals import current
  File "D:\TestingWeb3py\web2py\gluon\globals.py", line 16, in <module>
    from gluon._compat import pickle, StringIO, copyreg, Cookie, urlparse, PY2,iteritems, to_unicode, to_native, \
ImportError: cannot import name 'Cookie'

Thanks
SP



--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

黄祥

unread,
Jan 2, 2019, 4:32:13 AM1/2/19
to web2py-users
same here test using conda
$ uname
Darwin

$ python
-V
Python 3.7.1

$ git clone
--recursive https://github.com/web2py/web2py.git
$ cd web2py
$ git checkout modular

$ python setup
.py
Traceback (most recent call last):
 
File "setup.py", line 4, in <module>
   
from gluon.fileutils import tar, untar, read_file,
write_file
 
File "/Users/sugizo/Downloads/learn/web2py/gluon/__init__.py", line 35, in <module>
   
from .globals import current
 
File "/Users/sugizo/Downloads/learn/web2py/gluon/globals.py", line 16, in <module>
   
from gluon._compat import pickle, StringIO, copyreg, Cookie, urlparse, PY2, iteritems, to_unicode, to_native, \
ImportError: cannot import name 'Cookie' from 'gluon._compat' (/Users/sugizo/Downloads/learn/web2py/gluon/_compat.py)

$ python web2py
.py
Traceback (most recent call last):

 
File "web2py.py", line 21, in <module>
   
import gluon.widget
 
File "/Users/sugizo/Downloads/learn/web2py/gluon/__init__.py", line 35, in <module>
   
from .globals import current
 
File "/Users/sugizo/Downloads/learn/web2py/gluon/globals.py", line 16, in <module>
   
from gluon._compat import pickle, StringIO, copyreg, Cookie, urlparse, PY2, iteritems, to_unicode, to_native, \
ImportError: cannot import name 'Cookie' from 'gluon._compat' (/Users/sugizo/Downloads/learn/web2py/gluon/_compat.py)

best regards,
stifan

Carlos Cesar Caballero Díaz

unread,
Jan 2, 2019, 10:36:15 AM1/2/19
to web...@googlegroups.com

Guys, I think you need to include the "modular" branch of pydal too:

cd gluon/packages/dal/
git checkout modular

Greetings.


El 2/1/19 a las 4:32 a.m., 黄祥 escribió:

Carlos Cesar Caballero Díaz

unread,
Jan 2, 2019, 12:33:29 PM1/2/19
to web...@googlegroups.com

I like a LOT the idea, my initial tests seems to work ok in Python 3.6.7 on Ubuntu except the test_web ones are failing.

Tell me please, that one of the new year resolution is to have web2py in pypi :) That's something I would love to help make a reality.

This are my wishes:

1- pypi

2- The ability to:

pip install web2py
cd /home/myuser
git clone http://github.com/myuser/myapp.git
cd
myapp
web2py run

And start my app. Something like this will make distributing web2py apps a lot easier (even using pip)

3- An advanced welcome app template, including .gitignores, tests, and environment configurations for development and production.

4- A more flexible grid:
There will be awesome if we could pass to the grid the template for rendering forms
, or rendering buttons, cells etc... and define the logic for ordering fields (including virtual ones)

5- A CLI for applications, maybe using @cli decorators in controllers and maybe running them like "web2py --cli app/controller/function --param1=value1 --param2=value2"

6- A router that balances ease of use and power, maybe something in the middle of the two we have right now (I like the Yii2 framework routes style).

7- A more friendly error tickets for views (there can be difficult to find an error in a large view file), and maybe for reading them outside web2py (right now is really difficult to read errors accessing directly to the ticket files).

8- Some kind of "Modules system" that could make a lot easier the code reutilization.

With some guidance, I can use some hours/week and maybe include another dev for make this kind of features a reality. Even thougt I like the "web3py" idea, and I think that this kind of effort should be redirected to the new framework.

Greetings.


El 1/1/19 a las 7:04 p.m., Massimo Di Pierro escribió:

黄祥

unread,
Jan 2, 2019, 9:24:35 PM1/2/19
to web2py-users
thx carlos, here is the steps i took
git clone --recursive https://github.com/web2py/web2py.git

cd web2py
/gluon/packages/dal/
git checkout modular

$ python -V
Python 3.7.1
$ python
../../../setup.py
Traceback (most recent call last):

 
File "../../../setup.py", line 85, in <module>
    start
()
 
File "../../../setup.py", line 32, in start
    version
=read_file("VERSION").split()[1],
 
File "/Users/sugizo/Downloads/learn/web2py/gluon/fileutils.py", line 112, in read_file
    f
= open_file(filename, mode)
 
File "/Users/sugizo/Downloads/learn/web2py/gluon/fileutils.py", line 104, in open_file
    f
= open(filename, mode, encoding="utf8")
FileNotFoundError: [Errno 2] No such file or directory: 'VERSION'
$ python
../../../web2py.py
$ open http
://localhost:8000
$ open http://localhost:8000/admin/default/site

Version
2.17.2-stable+timestamp.2018.10.06.11.34.06
(Running on Rocket 1.2.6, Python 3.7.1)

suggestion
why the upgrade now to version 2.17.2 is active, just a suggestion think the button for upgrade now should be disable if the version is same or same like behaviour in previous version :
the button for upgrade is shown (Check for upgrades)
see below for test in python 2.7

$ python -V
Python 2.7.15 :: Anaconda, Inc.
$ python
../../../setup.py
/Users/sugizo/miniconda3/envs/python2_prod/lib/python2.7/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
 
""")

Traceback (most recent call last):
  File "../../../setup.py", line 85, in <module>
    start()
  File "
../../../setup.py", line 32, in start
    version=read_file("
VERSION").split()[1],
  File "
/Users/sugizo/Downloads/learn/web2py/gluon/fileutils.py", line 112, in read_file
    f = open_file(filename, mode)
  File "
/Users/sugizo/Downloads/learn/web2py/gluon/fileutils.py", line 102, in open_file
    f = open(filename, mode)
IOError: [Errno 2] No such file or directory: 'VERSION'
$ python ../../../web2py.py
$ open http://localhost:8000/admin/default/site
$ open http://localhost:8000

Traceback (most recent call last):
  File "/Users/sugizo/Downloads/learn/web2py/gluon/restricted.py", line 219, in restricted
    exec(ccode, environment)
  File "
/Users/sugizo/Downloads/learn/web2py/applications/welcome/models/db.py", line 95, in <module>
    auth.define_tables(username=False, signature=False)
  File "
/Users/sugizo/Downloads/learn/web2py/gluon/tools.py", line 2091, in define_tables
    super(Auth, self).define_tables(username, signature, migrate, fake_migrate)._table_signature_list
  File "
/Users/sugizo/Downloads/learn/web2py/gluon/authapi.py", line 350, in define_tables
    format='%(first_name)s %(last_name)s (%(id)s)'))
  File "
/Users/sugizo/Downloads/learn/web2py/gluon/packages/dal/pydal/base.py", line 590, in define_table
    table = self.lazy_define_table(tablename, *fields, **kwargs)
  File "
/Users/sugizo/Downloads/learn/web2py/gluon/packages/dal/pydal/base.py", line 624, in lazy_define_table
    polymodel=polymodel)
  File "
/Users/sugizo/Downloads/learn/web2py/gluon/packages/dal/pydal/adapters/base.py", line 798, in create_table
    return self.migrator.create_table(*args, **kwargs)
  File "
/Users/sugizo/Downloads/learn/web2py/gluon/packages/dal/pydal/migrator.py", line 296, in create_table
    sql_fields_old = pickle.load(tfile)
  File "
/Users/sugizo/miniconda3/envs/python2_prod/lib/python2.7/pickle.py", line 1384, in load
    return Unpickler(file).load()
  File "
/Users/sugizo/miniconda3/envs/python2_prod/lib/python2.7/pickle.py", line 864, in load
    dispatch[key](self)
  File "
/Users/sugizo/miniconda3/envs/python2_prod/lib/python2.7/pickle.py", line 892, in load_proto
    raise ValueError, "
unsupported pickle protocol: %d" % proto
ValueError: unsupported pickle protocol: 3

using python 2.7 can run admin but not for welcome app
Version
2.17.2-stable+timestamp.2018.10.06.11.34.06
(Running on Rocket 1.2.6, Python 2.7.15)
the button for upgrade is shown (Check for upgrades)

best regards,
stifan

Carlos Cesar Caballero Díaz

unread,
Jan 2, 2019, 9:58:56 PM1/2/19
to web...@googlegroups.com

Hi, this is working for me:

git checkout modular


cd web2py/gluon/packages/dal/
git checkout modular

cd ../../../


Greetings.


El 2/1/19 a las 9:24 p.m., 黄祥 escribió:

黄祥

unread,
Jan 2, 2019, 10:24:05 PM1/2/19
to web2py-users
yes, you r right, previous error before is due to the lack of step i took 
- git checkout must run twice in web2py folder and web2py/gluon/packages/dal
- execute python (setup.py) must be in web2py folder can't be from another path e.g. web2py/gluon/packages/dal then python ../../../setup.py will produce an error

git clone --recursive https://github.com/web2py/web2py.git

cd web2py
git checkout modular
cd gluon
/packages/dal/

git checkout modular
cd
../../../

python setup
.py
python web2py
.py

sandeep patel

unread,
Jan 3, 2019, 12:34:05 AM1/3/19
to web...@googlegroups.com
@Carlos Cesar Caballero,
I have taken the same steps as you suggested but I am getting the same error.

Robodia@DESKTOP-E4IOU2U MINGW64 /d/TestingWeb3py/web2py/gluon/packages/dal (modular)
$ python ../../../setup.py
Traceback (most recent call last):
  File "../../../setup.py", line 4, in <module>
    from gluon.fileutils import tar, untar, read_file, write_file
  File "D:\TestingWeb3py\web2py\gluon\__init__.py", line 35, in <module>
    from .globals import current
  File "D:\TestingWeb3py\web2py\gluon\globals.py", line 16, in <module>
    from gluon._compat import pickle, StringIO, copyreg, Cookie, urlparse, PY2,iteritems, to_unicode, to_native, \
ImportError: cannot import name 'Cookie'

Thanks
SP




--

Carlos Cesar Caballero Díaz

unread,
Jan 3, 2019, 8:16:49 AM1/3/19
to web...@googlegroups.com

Hi, most of the compatibility imports where moved from gluon to pydal compat module, so, if web2py does not find the 'Cookie' module, is because it either is not imported in gluon or pydal, so, I think that you are not using the modular branch of pydal. Start the steps again as @sitfan post in his last message.

Greetings.

El 3/1/19 a las 12:33 a.m., sandeep patel escribió:

sandeep patel

unread,
Jan 3, 2019, 9:26:29 AM1/3/19
to web...@googlegroups.com
@Carlos Cesar, I am in error trap. :(

I have done the same steps
git clone --recursive https://github.com/web2py/web2py.git
cd web2py
git checkout modular
cd gluon
/packages/dal/
git checkout modular
cd 
../../../

python setup
.py
python web2py
.py  

But I am still getting the same error.

Please give me some direction.
 
 Regards/
SP

黄祥

unread,
Jan 3, 2019, 9:43:45 AM1/3/19
to web2py-users
pls provide your environment (os and python version), the log errors indicate in windows but the shell sign is indicate in *nix environment
the step provided before tested in mac and also in run well in ubuntu n debian

docker pull ubuntu
docker run
-it ubuntu /bin/bash

docker pull debian
docker run
-it debian /bin/bash

apt update
apt install
-y git python-setuptools python3-setuptools
git clone
--recursive https://github.com/web2py/web2py.git

cd web2py
git checkout modular
cd gluon
/packages/dal/
git checkout modular
cd
../../../
python setup
.
py
python3 setup
.py
python web2py
.py
python3 web2py
.py

best regards,
stifan

sandeep patel

unread,
Jan 3, 2019, 10:00:06 AM1/3/19
to web...@googlegroups.com
@Stifan
OS Windows 10, Python 3.6.6
The shell sign is indicated in *nix environment because I am using Git Bash CLI.

Thanks
SP

--

黄祥

unread,
Jan 3, 2019, 4:42:06 PM1/3/19
to web2py-users
pardon, can't help further not using win env for the moment, but tested in python 3.6.6 work

docker pull ubuntu
docker run
-it ubuntu /bin/bash

apt update
apt install
-y curl bzip2 git
curl
-L -O -C - https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash
Miniconda*.sh
source
~/.bashrc
conda create -y -n python3 python=3.6.6
source activate python3

git clone --recursive https:/
/github.com/web2py/web2py.git

cd web2py
git checkout modular
cd gluon
/packages/dal/

git checkout modular
cd
../../../
python setup
.
py
python web2py
.py

best regards,
stifan

Massimo Di Pierro

unread,
Jan 5, 2019, 1:12:17 PM1/5/19
to web2py-users

If you are getting the error:
ImportError: cannot import name 'Cookie'

Either your are not installing the latest pydal or you have two versions (one in Python site-packages?). 
If you can import pydal from outside the web2py folder, then the problem is the latter. Un-install it because it will create problems.

Massimo

Massimo Di Pierro

unread,
Jan 5, 2019, 1:18:31 PM1/5/19
to web2py-users
Anybody wants to help
1) moving the scheduler and validator tests into pydal.
2) moving the template tests into gluon/packages/template/tests
3) create a gluon/packages/template/setup.py

Massimo

Carlos Cesar Caballero Díaz

unread,
Jan 6, 2019, 8:03:56 AM1/6/19
to web...@googlegroups.com

Hi Massimo, there is already a package called template in pypi, how should we name the new template module?

Greetings.

El 5/1/19 a las 1:18 p.m., Massimo Di Pierro escribió:

Carlos Cesar Caballero Díaz

unread,
Jan 6, 2019, 11:15:58 AM1/6/19
to web...@googlegroups.com

I have created a pydal-like structure for templates, including an initial setup.py and tests (there is also a fix for python 3 when running standalone), you can take a look at https://github.com/cccaballero/web2py/tree/modular_templates/gluon/packages/template

Greetings.

El 5/1/19 a las 1:18 p.m., Massimo Di Pierro escribió:
Anybody wants to help

Massimo Di Pierro

unread,
Jan 6, 2019, 11:56:50 AM1/6/19
to web2py-users
Fantastic! Thank you.
Will include and deploy today or tomorrow.

How should we call this package?

Massimo
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@googlegroups.com.

Carlos Cesar Caballero Díaz

unread,
Jan 6, 2019, 10:11:50 PM1/6/19
to web...@googlegroups.com

I know it's not too much originality, but perhaps web2py-template?

Or perhaps something like insole or markings.

Greetings.

El 6/1/19 a las 11:56 a.m., Massimo Di Pierro escribió:
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.

sandeep patel

unread,
Jan 6, 2019, 11:10:04 PM1/6/19
to web...@googlegroups.com
Thank you, Massimo,
Now it's working 

Thanks & Regards
Sandeep

--
Reply all
Reply to author
Forward
0 new messages