thanks for your comments. Please find the answers below:
> - is there a way to set up something like django "middleware" I mean
> something that happens always before the controller processing or
> always after it (before the output goes to browser).
There are two mechanism to do this, the wsgi way and the web2py way.
The wsgi way consists of inserting a wsgi app in between the web
server and web2py gluon/main.py/wsgibase. Where you do this depends
on the web server that you use.
The web2py ways is the following: any code in model files is executed
before any controller function. Any code in a controller outside
functions is executed before any function in that controller.
Of course you can also use decorators:
def before_and_after(f):
# do whatever you want before
d=f()
# do whatever you want after
return d
@before_and_after
def index(): return dict(message="hello world")
> - is there a way to define some function / variable visible in every
> controller? And in every template?
Anything defined in a model file is visible to all controllers and
all templates. Mind that models are executed in alphabetical order.
> - does w2p has the equivalent of reverse_url mapping?
Yes.
http://mdp.cti.depaul.edu/AlterEgo/default/show/67
http://mdp.cti.depaul.edu/AlterEgo/default/show/42
> I'm experimenting GAE, and so far I think w2p it's the best tool for
> the job. Good work!
>
I agree. :-)
> def before_and_after(f):
> def __tmp__():
> # do whatever you want before
> d=f()
> # do whatever you want after
> return d
> return __tmp__
>
> @before_and_after
> def index(): return dict(message="hello world")
>
> - does w2p has the equivalent of reverse_url mapping?Yes.
http://mdp.cti.depaul.edu/AlterEgo/default/show/67
http://mdp.cti.depaul.edu/AlterEgo/default/show/42