web2py 2.15.1 is OUT

597 views
Skip to first unread message

Massimo Di Pierro

unread,
Jul 10, 2017, 5:40:08 PM7/10/17
to web2py-users
It took a year. Thanks to everybody who contributed. There are a ton of bug fixes and speed improvements.

I would encourage everybody who contributed to add a comment in this thread explaining the main features/improvements they have made.

If anything does not work or was broken it is only fault and I will remedy if reported.

Massimo

Ricardo Pedroso

unread,
Jul 11, 2017, 7:20:35 AM7/11/17
to web...@googlegroups.com
I reported an issue (https://github.com/web2py/web2py/issues/1672)
with the 2.15.0b1 that still exists in 2.15.1

I think it was this pydal commit:
https://github.com/web2py/pydal/commit/fedd0c75ff1f84ce863a8785b31c762d9c3e55af#diff-68220c912f02a03fd8bce58415479334R1642

Ricardo
> --
> 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.
>

Massimo Di Pierro

unread,
Jul 11, 2017, 8:13:52 AM7/11/17
to web2py-users
check. I am sure there will be a 2.16.2 soon. ;-)

Paolo

unread,
Jul 11, 2017, 12:11:58 PM7/11/17
to web2py-users
There is a bit of confusion regarding release version, which one is correct 2.15.* or 2.16.*?
The main features are python3/pypy3 support, performance improvements, few core fixes 

Massimo Di Pierro

unread,
Jul 11, 2017, 3:39:04 PM7/11/17
to web2py-users
The one released yesterday is 2.15.1. The next one will be 2.15.2. (2.16.2 was a typo).

Richard Vézina

unread,
Jul 11, 2017, 3:39:48 PM7/11/17
to web2py-users
No confusion :  mdipierro R-2.15.1

Massimo's talk about releasing another version soon which will be 2.16.something

Richard

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

Richard Vézina

unread,
Jul 11, 2017, 3:40:22 PM7/11/17
to web2py-users
You right, my bad...

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

Richard Vézina

unread,
Jul 11, 2017, 3:44:06 PM7/11/17
to web2py-users
But 2.16.* would be good as support python3 is a major version... We could make things even more confusing by stating that web2py python3 supporting release will be web2py 3.00.*

Imagine with all the web3py discussions haha!

Just kidding, but I think version 3 is a good idea for this achievement, once we get there...

Richard

Anthony

unread,
Jul 11, 2017, 4:19:58 PM7/11/17
to web2py-users
One new feature is that in modern browsers (that support FormData), web2py Ajax components now support file uploads out of the box (no need for third-party plugins).

Anthony

Massimo Di Pierro

unread,
Jul 13, 2017, 1:03:31 PM7/13/17
to web2py-users
@Anthony,

could you provide a simple example?

Massimo

Anthony

unread,
Jul 13, 2017, 1:12:12 PM7/13/17
to web2py-users
On Thursday, July 13, 2017 at 1:03:31 PM UTC-4, Massimo Di Pierro wrote:
@Anthony,

could you provide a simple example?

model:

db.define_table('mytable',
   
Field('name'),
   
Field('photo', 'upload'))

controller:

def main_page():
   
return dict()

def form_component():
   
return dict(form=SQLFORM(db.mytable).process())

main_page.html view:

{{=LOAD('form_component', ajax=True)}}

With the above code, the file uploads for the db.mytable.photo field will now work (except in older browsers that do not support FormData). Previously, the way web2py.js handled Ajax form submissions (via jQuery.serialize) did not support file uploads, so the above code would fail to upload files for the db.mytable.photo field.

Anthony

lyn2py

unread,
Jul 13, 2017, 1:16:31 PM7/13/17
to web2py-users
I'm using a simple query to get aggregate:

max = db.table.date.max()
row
= db().select(max)


But I ran into this error:

Traceback (most recent call last):
  File "/Users/web2py/web2py/gluon/main.py", line 445, in wsgibase
    serve_controller(request, response, session)
  File "/Users/web2py/web2py/gluon/main.py", line 180, in serve_controller
    page = run_controller_in(request.controller, request.function, environment)
  File "/Users/web2py/web2py/gluon/compileapp.py", line 660, in run_controller_in
    vars = vars.xml()
  File "/Users/web2py/web2py/gluon/packages/dal/pydal/objects.py", line 2497, in xml
    rv = self.db.represent('rows_xml', self)
  File "/Users/web2py/web2py/gluon/packages/dal/pydal/base.py", line 834, in represent
    return self.representers[name](*args, **kwargs)
  File "/Users/web2py/web2py/gluon/sqlhtml.py", line 3319, in __init__
    tablemap = dict(((f.tablename, f.table) for f in fieldmap.values()))
  File "/Users/web2py/web2py/gluon/sqlhtml.py", line 3319, in <genexpr>
    tablemap = dict(((f.tablename, f.table) for f in fieldmap.values()))
AttributeError: 'Expression' object has no attribute 'tablename'


Kindly assist.

Richard Vézina

unread,
Jul 13, 2017, 1:22:01 PM7/13/17
to web2py-users
@lyn2py, seems more a issue with naming in your model than anything else... Can you show us your model?

--

lyn2py

unread,
Jul 13, 2017, 1:36:09 PM7/13/17
to web2py-users
Here it is...

db.define_table('TABLE_of_sites', 
Field('site_id', 'reference sites'),
Field('title', 'string'), 
Field('date','datetime'),
...
Field('updated','datetime', update=request.now, writable=False),
format='%(site_id)s'
)

There are multiple entries for a particular title, so I want to get the MAX(date) entry.

This is the query I used (result = not working):
table = 'TABLE_of_sites'
max 
= db[table].date.max()
row 
= db().select(max)


Other queries on the table work fine, but not aggregates. I tried count(), max() and they both don't work.

Queries that work are the straightforward ones:
db(db[table]).select()

In fact I also tried distinct and there's an error too, I will make a separate post.

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

lyn2py

unread,
Jul 13, 2017, 1:48:10 PM7/13/17
to web2py-users
Table code:
db.define_table('TABLE_of_sites', 
Field('site_id', 'reference sites'),
Field('title', 'string'), 
Field('date','datetime'),
...
Field('updated','datetime', update=request.now, writable=False),
format='%(site_id)s'
)


In controller:
table = db['TABLE_of_sites']
rows = db(table).select(distinct=table.title)

Gives the error:
ProgrammingError: missing FROM-clause entry for table "table_of_sites"
LINE 1: SELECT DISTINCT ON (TABLE_of_sites.title) "TABLE_of...
                            ^

I printed the sql query that resulted from the above code. It has the FROM-clause, so I don't know why it would give the error. This is the printed query:
SELECT DISTINCT ON (TABLE_of_sites.title) "TABLE_of_sites"."id", "TABLE_of_sites"."site_id", "TABLE_of_sites"."date", "TABLE_of_sites"."title" FROM "TABLE_of_sites" WHERE ("TABLE_of_sites"."id" IS NOT NULL);

I need to select 1 row for entries that appear multiple times for a particular title, hence I'm using distinct (or aggregates like max() - details in my previous post) but both are not working.

Thank you for your time and assistance!





On Tuesday, July 11, 2017 at 5:40:08 AM UTC+8, Massimo Di Pierro wrote:

lyn2py

unread,
Jul 13, 2017, 2:11:39 PM7/13/17
to web2py-users
Following this lead https://stackoverflow.com/questions/34708963/error-missing-from-clause-entry-for-table

I discovered that if we add double quotes to the tablename, for all instances of the tablename, like this:
"TABLE_of_sites"

Then the query will work.

Richard Vézina

unread,
Jul 13, 2017, 2:26:57 PM7/13/17
to web2py-users
Are you using rname feature?

If so, the issue may need to be further investigate as why SELECT DISTINCT ON (TABLE_of_sites.title) is not double quoted and all the other table_name and field instance are...

So maybe the flaw is somewhere in the escaping related to rname feature...

Richard

--
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+unsubscribe@googlegroups.com.

Dave S

unread,
Jul 13, 2017, 4:04:27 PM7/13/17
to web2py-users


On Tuesday, July 11, 2017 at 12:39:04 PM UTC-7, Massimo Di Pierro wrote:
The one released yesterday is 2.15.1. The next one will be 2.15.2. (2.16.2 was a typo).

Are the book pull requests to be included?  There were a couple of issues.

/dps
 

Anthony

unread,
Jul 13, 2017, 5:43:57 PM7/13/17
to web2py-users
Are you saying that used to work but doesn't any longer?

How about db(db.table).select(max)?

Anthony

Leonel Câmara

unread,
Jul 13, 2017, 8:17:11 PM7/13/17
to web2py-users
Note this is deprecated:

row = db().select(max)

Calling db() like that without a query will break common filters for instance.

lyn2py

unread,
Jul 13, 2017, 9:04:27 PM7/13/17
to web2py-users
No I am not using the rname feature
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.

lyn2py

unread,
Jul 13, 2017, 9:13:43 PM7/13/17
to web2py-users
Thank you Leonel,

I actually have a very complex query, and it ran into the error I mentioned. In my query I have:
db(query).select(other_fields, aggregate, groupby=...etc..., orderby=...etc...)

and I ran into the error. So I tried to identify if it was my complex query throwing the error, my model or some other part, and over 4 hours (too long, I know...) I narrowed down to the aggregate, I tested specifically to the example provided by the web2py book. It still gave the same error.

In my normal use-case, I have a "query", but it's still good to know and add to the book that it is deprecated.

Dave S

unread,
Jul 13, 2017, 9:20:21 PM7/13/17
to web2py-users


On Thursday, July 13, 2017 at 2:43:57 PM UTC-7, Anthony wrote:
Are you saying that used to work but doesn't any longer?


There are 3 examples in the book at the link.  They work in 2.14.6 using -S (and I did cut-n-paste to check).



 
How about db(db.table).select(max)?

Anthony


/dps

 

lyn2py

unread,
Jul 13, 2017, 9:35:17 PM7/13/17
to web2py-users
Thank you Anthony. I always appreciate your input.

I recall using the aggregates max() and count() before and they worked fine following the book. That was quite long ago. However, this time, I did not try on the "old" web2py version. I upgraded to 2.15.1 and continued to code in it.

Using
db(db.table).select(max)



Gave a longer traceback:
Traceback (most recent call last):
  File "/Users/web2py/web2py/gluon/restricted.py", line 219, in restricted
    exec(ccode, environment)
  File "<string>", line 83, in <module>
  File "/Users/web2py/web2py/gluon/globals.py", line 422, in write
    self.body.write(to_native(xmlescape(data)))
  File "/Users/web2py/web2py/gluon/html.py", line 125, in xmlescape
    return to_bytes(data.xml())
  File "/Users/web2py/web2py/gluon/html.py", line 960, in xml
    (fa, co) = self._xml()
  File "/Users/web2py/web2py/gluon/html.py", line 952, in _xml
    co = b''.join([xmlescape(component) for component in self.components])
  File "/Users/web2py/web2py/gluon/html.py", line 125, in xmlescape
    return to_bytes(data.xml())
  File "/Users/web2py/web2py/gluon/html.py", line 960, in xml
    (fa, co) = self._xml()
  File "/Users/web2py/web2py/gluon/html.py", line 952, in _xml
    co = b''.join([xmlescape(component) for component in self.components])
  File "/Users/web2py/web2py/gluon/html.py", line 125, in xmlescape
    return to_bytes(data.xml())
  File "/Users/web2py/web2py/gluon/html.py", line 960, in xml
    (fa, co) = self._xml()
  File "/Users/web2py/web2py/gluon/html.py", line 952, in _xml
    co = b''.join([xmlescape(component) for component in self.components])
  File "/Users/web2py/web2py/gluon/html.py", line 125, in xmlescape
    return to_bytes(data.xml())
  File "/Users/web2py/web2py/gluon/html.py", line 960, in xml
    (fa, co) = self._xml()
  File "/Users/web2py/web2py/gluon/html.py", line 952, in _xml
    co = b''.join([xmlescape(component) for component in self.components])
  File "/Users/web2py/web2py/gluon/html.py", line 125, in xmlescape
    return to_bytes(data.xml())
  File "/Users/web2py/web2py/gluon/html.py", line 960, in xml
    (fa, co) = self._xml()
  File "/Users/web2py/web2py/gluon/html.py", line 952, in _xml
    co = b''.join([xmlescape(component) for component in self.components])
  File "/Users/web2py/web2py/gluon/html.py", line 125, in xmlescape
    return to_bytes(data.xml())
  File "/Users/web2py/web2py/gluon/packages/dal/pydal/objects.py", line 2497, in xml
    rv = self.db.represent('rows_xml', self)
  File "/Users/web2py/web2py/gluon/packages/dal/pydal/base.py", line 834, in represent
    return self.representers[name](*args, **kwargs)
  File "/Users/web2py/web2py/gluon/sqlhtml.py", line 3319, in __init__
    tablemap = dict(((f.tablename, f.table) for f in fieldmap.values()))
  File "/Users/web2py/web2py/gluon/sqlhtml.py", line 3319, in <genexpr>
    tablemap = dict(((f.tablename, f.table) for f in fieldmap.values()))
AttributeError: 'Expression' object has no attribute 'tablename'

lyn2py

unread,
Jul 13, 2017, 10:42:49 PM7/13/17
to web2py-users
Anthony, pls see https://groups.google.com/d/msg/web2py/h4b4xz2NzNM/QHSoRfrcCAAJ

If we put double quotes on the table name, which happens to not be there for aggregates and distinct then the sql query will work.


On Friday, July 14, 2017 at 5:43:57 AM UTC+8, Anthony wrote:

Dave S

unread,
Jul 14, 2017, 4:12:39 AM7/14/17
to web2py-users


On Thursday, July 13, 2017 at 6:20:21 PM UTC-7, Dave S wrote:


On Thursday, July 13, 2017 at 2:43:57 PM UTC-7, Anthony wrote:
Are you saying that used to work but doesn't any longer?


There are 3 examples in the book at the link.  They work in 2.14.6 using -S (and I did cut-n-paste to check).


They seem to work in 2.15.0b1.

(Note:  the examples depend on earlier examples, starting at "Other Operators".)




 
How about db(db.table).select(max)?

Anthony


/dps


Me again.
-d

Dave S

unread,
Jul 14, 2017, 4:14:14 AM7/14/17
to web2py-users
Do we need another pull request on the book, since the examples are there?  (They were last edited in 2013, it appears.)

/dps
 

Dave S

unread,
Jul 14, 2017, 9:07:52 PM7/14/17
to web2py-users


On Friday, July 14, 2017 at 1:12:39 AM UTC-7, Dave S wrote:


On Thursday, July 13, 2017 at 6:20:21 PM UTC-7, Dave S wrote:


On Thursday, July 13, 2017 at 2:43:57 PM UTC-7, Anthony wrote:
Are you saying that used to work but doesn't any longer?


There are 3 examples in the book at the link.  They work in 2.14.6 using -S (and I did cut-n-paste to check).


They seem to work in 2.15.0b1.

(Note:  the examples depend on earlier examples, starting at "Other Operators".)

And now I can add "work in 2.15.1" to the report.

/dps
 

vince

unread,
Jul 17, 2017, 8:11:58 AM7/17/17
to web2py-users
i download from https://mdipierro.pythonanywhere.com/examples/static/web2py_src.zip

on first line of changelog it's 2.15.0b1

and when i run web2py.py error as below

Traceback (most recent call last):
  File "./web2py.py", line 21, in <module>
    import gluon.widget
  File "/home/web2py/gluon/__init__.py", line 38, in <module>
    from .dal import DAL, Field
  File "/home/web2py/gluon/dal.py", line 19, in <module>
    from gluon import sqlhtml
  File "/home/web2py/gluon/sqlhtml.py", line 32, in <module>
    from pydal.helpers.methods import smart_query, bar_encode, _repr_ref, merge_tablemaps
ImportError: cannot import name merge_tablemaps 

-vince

Leonel Câmara

unread,
Jul 17, 2017, 8:54:56 AM7/17/17
to web2py-users
Vince that seems like a bug in the way you updated web2py you seem to be using the old DAL.

Carlos Costa

unread,
Jul 17, 2017, 2:06:47 PM7/17/17
to web2py-users
I have a problem with this version.

This does not work anymore:

    db.define_table('tabela', Field('campo'))
    form = SQLFORM.factory(db.tabela.campo)

I throws this:

Traceback (most recent call last
):
File "C:\Users\carlos.costa\Downloads\web2py\gluon\restricted.py", line 219, in restricted
exec(ccode, environment)
File "C:/Users/carlos.costa/Downloads/web2py/applications/teste/controllers/default.py", line 66, in <module>
File "C:\Users\carlos.costa\Downloads\web2py\gluon\globals.py", line 409, in <lambda>
self._caller = lambda f: f()
File "C:/Users/carlos.costa/Downloads/web2py/applications/teste/controllers/default.py", line 13, in teste
form = SQLFORM.factory(db.tabela.campo)
File "C:\Users\carlos.costa\Downloads\web2py\gluon\sqlhtml.py", line 1919, in factory
return SQLFORM(DAL(None).define_table(table_name, *fields),
File "C:\Users\carlos.costa\Downloads\web2py\gluon\packages\dal\pydal\base.py", line 587, in define_table
table = self.lazy_define_table(tablename, *fields, **args)
File "C:\Users\carlos.costa\Downloads\web2py\gluon\packages\dal\pydal\base.py", line 599, in lazy_define_table
table = table_class(self, tablename, *fields, **args)
File "C:\Users\carlos.costa\Downloads\web2py\gluon\packages\dal\pydal\objects.py", line 351, in __init__
field.bind(self)
File "C:\Users\carlos.costa\Downloads\web2py\gluon\packages\dal\pydal\objects.py", line 1633, in bind
'Field %s is already bound to a table' % self.longname)
ValueError: Field tabela.campo is already bound to a table

Leonel Câmara

unread,
Jul 17, 2017, 2:09:01 PM7/17/17
to web2py-users
Carlos your problem was already reported:

Before the next release which will have the fix the workaround is:

form = SQLFORM.factory(db.tabela.campo.clone())


bonbe

unread,
Aug 2, 2017, 9:13:31 AM8/2/17
to web2py-users
The same thing happened to me.
Please use Python3.


2017年7月17日月曜日 21時11分58秒 UTC+9 vince:

Anthony

unread,
Aug 2, 2017, 9:24:31 AM8/2/17
to web2py-users
On Wednesday, August 2, 2017 at 9:13:31 AM UTC-4, bonbe wrote:
The same thing happened to me.
Are you saying that has happened with the latest release (2.15.2), or only with 2.15.0b1?

Please use Python3.
web2py should continue to work with Python 2, so there is no need to move to Python 3. If there is a bug, it will be fixed.

Anthony

Richard Vézina

unread,
Aug 2, 2017, 12:26:45 PM8/2/17
to web2py-users
Don't forget to copy/paste (backup) you app before you try Python 3, because there is no way back with the app once you use it under python 3 as certain stuff are modify by python 3 that let your app unusable with python 2 after.

Richard

--
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+unsubscribe@googlegroups.com.

Anthony

unread,
Aug 2, 2017, 9:53:19 PM8/2/17
to web2py-users
On Wednesday, August 2, 2017 at 12:26:45 PM UTC-4, Richard wrote:
Don't forget to copy/paste (backup) you app before you try Python 3, because there is no way back with the app once you use it under python 3 as certain stuff are modify by python 3 that let your app unusable with python 2 after.

That sounds extreme, as you can certainly simply redeploy the original Python 2 code in a Python 2 environment -- there is a way back.

Anthony

Richard Vézina

unread,
Aug 2, 2017, 11:26:31 PM8/2/17
to web2py-users
I recall having conversation about that, I am not sure, I think it language file or pickle objects that get modify in a no way back manner... But, sure the app code it not affected... I should retrieve this exchange... will try tomorrow.

Richard

--

Anthony

unread,
Aug 3, 2017, 11:40:00 AM8/3/17
to web2py-users
On Wednesday, August 2, 2017 at 11:26:31 PM UTC-4, Richard wrote:
I recall having conversation about that, I am not sure, I think it language file or pickle objects that get modify in a no way back manner...

I think only the sessions and error tickets should be affected, as they are pickled. Language files should be OK -- they are just plain Python code (containing a Python dictionary).

Regarding sessions, simply copying/backing up the old sessions might not be particularly helpful -- if you do revert back to the old sessions, they will end up being outdated anyway.

The bigger point, though, should be that it is not intended that you would switch back and forth between Python 2 and Python 3 using the same application folders -- pick a Python version and stick with it.

Anthony

Alex

unread,
Aug 3, 2017, 5:57:46 PM8/3/17
to web2py-users
I tested the latest version 2.15.2 and I've got a problem when accessing ajax post parameters with web2py under Python 3.

The client sends a PUT request using jquery like this:
$.ajax('<url>', {
    data: JSON.stringify({
        report: report
        outputFormat: 'pdf'
    }),
    type: "PUT", contentType: "application/json",
    ...


in the controller I access the parameters, e.g.
output_format = request.vars.outputFormat

when using Python 2.7 the variable output_format is set to 'pdf' as expected. When using Python 3.5 the variable is None.

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

Leonel Câmara

unread,
Aug 3, 2017, 8:39:30 PM8/3/17
to web2py-users
Alex please create an issue in github, that's a genuine python 3 bug, exactly the kind we want to find during this experimental python 3 support phase.
Reply all
Reply to author
Forward
0 new messages