ARTICLE: The good and bad about web2py

571 views
Skip to first unread message

David Marko

unread,
Aug 1, 2010, 1:28:30 PM8/1/10
to web2py-users

Tim Michelsen

unread,
Aug 1, 2010, 1:53:14 PM8/1/10
to web...@googlegroups.com
> http://www.ahmedsoliman.com/2010/07/29/the-good-and-bad-about-web2py/
nice one. and fair.

Would lo e to see a reaction from Massimo.

Scott

unread,
Aug 1, 2010, 4:36:25 PM8/1/10
to web2py-users
Here are my thoughts, point by point:

- web2py does support unit testing as it uses python code. I think
the article author means you cannot currently set up unit tests within
the administration console. You can configure tests as much or as
little as you like from the command line.

- I think the article author should elaborate on the meaning of the
phrase “used in a twisted way to design the framework”. I don't see
anything twisted about the implementation; web2py is a WSGI
application. Personally, I think following Style Guide for Python
Code (PEP-8) is a good thing. Why is following the standard Style
Guide a bad thing? It promotes readability, consistency and
reusability.

- I cannot disagree with the author more on his view of error
reporting. I prefer having the list of errors viewable from the
administration console so I can refer to previous errors without
grepping through logs. Not only that, but web2py built-in error
reporting gives you hyperlinks to the files so you can track down the
root cause. This is a Good Thing™! Furthermore, you could just
enable & tail the debug log if it bothers you that much.

On Aug 1, 1:28 pm, David Marko <dma...@tiscali.cz> wrote:
> http://www.ahmedsoliman.com/2010/07/29/the-good-and-bad-about-web2py/

Scott

unread,
Aug 1, 2010, 4:42:24 PM8/1/10
to web2py-users
I missed the last few sections when I pasted in my response :-)

- web2py uses the DAL as documented here: http://en.wikipedia.org/wiki/Web2py#Database_handling;
why is an ORM needed?

- web2py has excellent IDE support through Eclipse and Wing IDE.
Maybe we need more details on his issue.

- As he rightly points out the single-core question is an interpreter
limitation of sorts and really has nothing to do with web2py. That
having been said, you can easily set up multiple instances and load-
balance them. All of which is heavily documented in the scalability
section of the web2py book.

Jason Brower

unread,
Aug 1, 2010, 4:56:47 PM8/1/10
to web...@googlegroups.com

I agree about the unit testing. It woud really put web2py on another level.
I think underscores are flipping awsome. Camelcase makes me sick. :P
ide integration would be nice but we are on our way with that and eclipse. Trying that out soon.
I personally feel that the error reporting is pretty good. I would how ever like to see a way to report errors to an email or otherwise. That way i dont have to look around for them. Annoying as i cant view the errors without copying them locally first off the web server and reading them from my personal computer. Hence why i felt we need a console based reader for web2py error files.
Otherwise... Good points all round. Lets see if we can improve on'em.
Jb

----- Original message -----
> http://www.ahmedsoliman.com/2010/07/29/the-good-and-bad-about-web2py/

Robert O'Connor

unread,
Aug 1, 2010, 5:08:49 PM8/1/10
to web...@googlegroups.com

-Rob


On Sun, Aug 1, 2010 at 4:42 PM, Scott <blues...@gmail.com> wrote:
I missed the last few sections when I pasted in my response :-)

- web2py uses the DAL as documented here: http://en.wikipedia.org/wiki/Web2py#Database_handling;
why is an ORM needed?

- web2py has excellent IDE support through Eclipse and Wing IDE.
Maybe we need more details on his issue.
It also happens to work *out of the box* with IntelliJ IDEA --- with full debugging support! 

mdipierro

unread,
Aug 1, 2010, 6:10:45 PM8/1/10
to web2py-users
This was my response. It is awaiting moderation:

Hello Ahmed. Nice article.

A few comments:
web2py runs with Jython. We just consider CPython the reference
platform. There is a known bug in the Java regex library that sun
marked as wontfix that can cause occasional runaway problems with
parsing templates in Jython. It is not a web2py specific issue but I
thought I'd mention it.

You can use unit tests with web2py. web2py it self has unit tests in
the gluon/tests folder. You can run unit tests for your apps from the
shell (as you would do in other Python frameworks) although you cannot
run them through the web IDE. The web IDE only supports doctests and
you are correct about that.

Web2py is known to work with WingIDE, Eclipse and IntelliJ.

It is true that web2py does not distinguishes production from
debugging mode but to clarify: this is because webp2y always in
production mode yet it always logs all the errors. If the current user
is logged in as administator he/she has access to the error tickets
and error tracebacks.

Web2py follows PEP8 internally but it does not import application
code, executes it. In this environment it exposes some symbols. Some
symbols are per-http-request. Some symbols are system wide. The latter
are all caps because should be treated as constants and not modified.
I feel this is consistent with PEP8. The naming scheme is explained in
the first chapter of the manual.

You are also right that web2py has a DAL, not an ORM. The main
difference is that in a ORM a table is a class and a record is an
instance of that class. In the web2py DAL the table concept is a class
but each table is an instance and each record is a dictionary. In my
view both approaches are object oriented. For example this is a query
with the web2py DAL:

for row in db(db.mytable.myfield>0).select(): print row.myfield

and this the same query with the Django ORM:

for row in Mytable.objects.filter(myfield__lt=0): print row.myfield

In my opinion the former looks more OO than the latter.

Thadeus Burgess

unread,
Aug 1, 2010, 6:33:07 PM8/1/10
to web...@googlegroups.com
I must point out on the testing standpoint:

http://packages.python.org/web2py_utils/test_runner.html

--
Thadeus

Scott

unread,
Aug 1, 2010, 7:00:17 PM8/1/10
to web2py-users
I knew IntelliJ had a few plugins for PHP, Ruby, etc. but didn't think
the Python plugin made it out of beta. I'll go take another look.
Thanks!

On Aug 1, 5:08 pm, "Robert O'Connor" <robby.ocon...@gmail.com> wrote:
> -Rob
>

mdipierro

unread,
Aug 1, 2010, 8:30:17 PM8/1/10
to web2py-users
I should remember to reference that in the new book. :-)

On Aug 1, 5:33 pm, Thadeus Burgess <thade...@thadeusb.com> wrote:
> I must point out on the testing standpoint:
>
> http://packages.python.org/web2py_utils/test_runner.html
>
> --
> Thadeus
>

Michele Comitini

unread,
Aug 2, 2010, 5:36:18 AM8/2/10
to web...@googlegroups.com
Massimo since you are a real gentleman you have been too polite... ;)

DAL vs ORM: the fact that DAL uses a clean functional approach does not mean that is not OO...

"Python magic was all over the place, variables defined globally are allover, you cannot see real OO in the design"

I only agree that Python is magic, but that is the only thing I agree with.  Probably a long exposure to COO (Class Object Oriented languages
such as java) causes this misunderstanding with Python beginners.  Indeed Python is a truly OO languages and web2py uses that.

Ok enough...

ciao,
mic


2010/8/2 mdipierro <mdip...@cs.depaul.edu>

Ahmed Soliman

unread,
Aug 2, 2010, 6:51:42 AM8/2/10
to web2py-users
Ok, I would like to elaborate more on the points I've mentioned.

1- Web2py does not support unit testing out of the box and if you want
to hack everything to get unit testing well integrated you can but
this still doesn't mean the framework support unit testing, and by
that I mean the ability to test complete scenarios, have you tried to
write a unit test for controller that has SQLFORM in it? the double-
submission check will make your life miserable if you tried to do unit
tests that simulates form submissions. Also you will need to do a lot
to create correct fixtures that would bring the web2py environment up
and down before and after every test. Plus, there is no selenium
testing integration like how other frameworks do.

2- By saying "twisted" means that you have things that are
automagically imported for you and many things are imported by default
according to import_all, also you have a lot of variables like
"response, request, session, etc." that are magically inserted into
the execution environment, such design is OK but not Good, as I can't
see the context and there is a little of referential transparency in
there. You can't see what's being passed or imported, neither the IDE.

3- In error reporting, If you tried to write a mistake in the
template, the question is, does it show you the error "correctly"?
does it show you the right line number as in your source file?
4- About the DAL and not ORM, that's OK and I understand that you
chosen the DAL choice based on your experience with ORMs but from my
personal point of view that your implementation of DAL is too close
from being an ORM but without a decent way of defining the entities,
you simply nest everything into a possibly one or more calls to create
tables with validators in a pure functional way. My problem with that
is that "flat is better than nested" and the code becomes scattered
especially in the model

4- Yes, I already explained that CPython implementation is the real
limitation and not web2py, this is a python-related issue and not
web2py but still web2py is affected.

5- Yes, Python does work on Eclipse, IntelliJ, etc. but does web2py
work smoothly and easily? for instance, to get web2py working
correctly on eclipse (PyDev) you will need to put stupid nonsense
imports ( if 0: import ) on the top of every file because of the
"magic" I mentioned before., you will need to manually redefine
request, response, session, etc. variables in that dummy if condition.
You don't get proper auto completion because almost everything happen
in the runtime (like dicts masked as attributed objects). So, simply,
By design no IDE can help you much unless we hardcoded much of that
stuff into the IDE itself.

6- I also would like to add that the current design on the plugin
system, looks more like a hack rather than a modular, conflict-safe
scalable system.

Btw, I still like web2py very much and I would like to contribute when
possible on making things better but that might include general
philosophy changes.1

Thanks for the great community.

On Aug 2, 12:36 pm, Michele Comitini <michele.comit...@gmail.com>
wrote:
> Massimo since you are a real gentleman you have been too polite... ;)
>
> DAL vs ORM: the fact that DAL uses a clean functional approach does not mean
> that is not OO...
>
> "Python magic was all over the place, variables defined globally are
> allover, you cannot see real OO in the design"
>
> I only agree that Python is magic, but that is the only thing I agree with.
> Probably a long exposure to COO (Class Object Oriented languages
> such as java) causes this misunderstanding with Python beginners.  Indeed
> Python is a truly OO languages and web2py uses that.
>
> Ok enough...
>
> ciao,
> mic
>
> 2010/8/2 mdipierro <mdipie...@cs.depaul.edu>

Michele Comitini

unread,
Aug 2, 2010, 7:59:30 AM8/2/10
to web...@googlegroups.com
Ahmed,

Ok I understand now point 2.   I think that is "dependency injection" and "inversion of control", web2py uses it.
The problem you mention is real: debugging is harder because you don't know where things come from.
This is common to  programs that uses IoC, but is good for code reuse and unit testing (of  web2py framework itself).


2010/8/2 Ahmed Soliman <ah...@farghal.com>

mdipierro

unread,
Aug 2, 2010, 8:03:02 AM8/2/10
to web2py-users
Thanks Ahmed for the clarifications. Having feedback from users is
very important. :-)

Phyo Arkar

unread,
Aug 2, 2010, 10:41:36 AM8/2/10
to web...@googlegroups.com
For me . Web2py completions works flawlessly under Eclipse + PyDEV

Just follow Mr.Freeze post on web2py slice http://www.web2pyslices.com/main/slices/take_slice/2

and add on each controller : 

from applications.sExtract.modules.doctypes import *
from gluon.sql import *
from gluon.html import *
from gluon.globals import Response, Session, Request 
 
global RESPONSE , REQUEST, SESSION , db
REQUEST = Request()
REQUEST = request
SESSION = Session()
SESSION = session
RESPONSE = Response()

Jonathan Lundell

unread,
Aug 2, 2010, 11:17:58 AM8/2/10
to web...@googlegroups.com
On Aug 2, 2010, at 2:36 AM, Michele Comitini wrote:

> "Python magic was all over the place, variables defined globally are allover, you cannot see real OO in the design"
>
> I only agree that Python is magic, but that is the only thing I agree with. Probably a long exposure to COO (Class Object Oriented languages
> such as java) causes this misunderstanding with Python beginners. Indeed Python is a truly OO languages and web2py uses that.

Rails is full of magic, too; it's part of the charm.

I do think (I'm repeating myself) that the magic could be better documented. Including being a little more explicit about what's happening in the global namespace, and how it relates to code in models, controllers & views.

Tim Michelsen

unread,
Aug 2, 2010, 4:54:04 PM8/2/10
to web...@googlegroups.com
> 5- Yes, Python does work on Eclipse, IntelliJ, etc. but does web2py
> work smoothly and easily? for instance, to get web2py working
> correctly on eclipse (PyDev) you will need to put stupid nonsense
> imports ( if 0: import ) on the top of every file because of the
> "magic" I mentioned before., you will need to manually redefine
> request, response, session, etc. variables in that dummy if condition.
> You don't get proper auto completion because almost everything happen
> in the runtime (like dicts masked as attributed objects). So, simply,
> By design no IDE can help you much unless we hardcoded much of that
> stuff into the IDE itself.
Oh yes, this is actually what made my efforts to document the framework
with Sphinx quite unsuccessful last year:
things only work when executed but Sphinx is designed for importing code.

Iceberg

unread,
Aug 3, 2010, 10:34:40 AM8/3/10
to web2py-users
On Aug 2, 4:56 am, Jason Brower <encomp...@gmail.com> wrote:
> Annoying as i can't view the errors without copying them locally first off the web server and reading them from my personal computer.


You can, just configure properly the web2py admin interface on your
production site.

Even you did not setup or don't want the admin on production server,
it is still a good thing that the errors can be copied to development
server and view and debug. Isn't i?


> Hence why i felt we need a console based reader for web2py error files.
Why a separated error viewer is needed? Don't you need an entire
development environment, as soon as after viewing the error and start
debug?

Regards,
iceberg
Reply all
Reply to author
Forward
0 new messages