Right now the @require decorator included in Authority falls into the
category of "the simplest thing that could possibly work". Its
biggest problem ATM, is that it takes no arguments, which it will need
to in order to take conditions like "has_permission", etc.
As I understand it there are basically two ways to do this, the
"nested functions" method, and the "class-based method". This article
shows an example of each with a simple decorator:
http://muharem.wordpress.com/2006/10/19/python-decorator-mini-study-part-2-of-3/
My question to the list is: Which should we use? Personally I find
the class-based method easier to understand, but I'd be interested in
hearing other's experiences with these kind of issues.
Another issue with this decorator is that because it checks the user
object, which is stored in the session, it will need access to at
least the beaker session. Right now it is getting this from the WSGI
environment, which is brought in using pylons. In the interest of
decoupling from Pylons, is there another (better) way of getting the
session object?
Also, any ideas/examples on how to test the require decorator (or
decorators in general) would be most welcome.
Kevin Horn