Q:

Use of @auth decorators in web2py

For many functions of my app, it requires the use of
@auth.requires_login()

Does this mean that ALL the code relating to Auth object defined in the model have to be run in order to serve the requests to an action that requires the decorator? If not, how should I re-factor the code to minimize unnecessary execution of portions of Auth code?

A:

Just to check whether the user is logged in does not necessarily require that all the Auth code be run. You do have to instantiate the Auth object, but you don't have to run auth.define_tables() (which defines all the Auth tables). Note, if you don't define the Auth tables, the auth.navbar() helper function will not work as is because it tries to reference an attribute of the auth_user table. As a workaround, you could create a custom navbar function (which you might want to do anyway), or define at least that one table.

