Hi,

I think we found a serious bug (at least, we hope it is not a designed
feature). If you create a simple controller (like test.py) with the
following actions:
def test():
  return dict()

@auth.requires_permission('foo bar')
def test2():
  return dict()

And a simple view (like test.html) with:
{{extend 'layout.html'}}
<h1>Test</h1>
{{=response.toolbar()}}

And then open the first action ( <app>/test/test ) in your browser and
inspect the db stats from the response toolbar, you'll see:
SELECT  auth_permission.group_id FROM auth_permission WHERE
(((auth_permission.name = 'foo bar') AND (auth_permission.table_name =
'')) AND (auth_permission.record_id = 0));

If you comment out the decorator, there are no db queries. So this
means that somehow all decorators are executed and because the do
check the database you will get unnecessary database queries. If you
have a controller file with for example 10 actions and all of them
have a auth decorator, you will at least get 10 queries for this
simple single request. We noticed this because I had multiple
decorated actions in one controller file and we got about 30 db
queries for a simple request (like test above). Most of the queries
were of course even duplicates, because of the same decorator.

We noticed this behavior on Version 1.99.2 (2011-09-26 06:55:33)
stable and Version 1.99.3 (2011-11-16 22:36:13) dev

I think this should be fixed, because this will result in unnecessary
bad performance in larger apps.

Regards,
Ids

Reply via email to