Access to static members from inside a method decorator?

urielka uriel.katz at gmail.com
Fri Oct 6 07:49:35 EDT 2006


no need for all that,i wrote a basic Ajax framework for cherrypy that
features a Ajax.Net feature,exposing functions to JavaScript via
attributes(or in python via decorators),here is a decorator that run
one time(i.e. before running the actual code) and get the name of the
class
[code]
def AddFunction(func):
        stack=inspect.stack()
        ClsName=stack[1][3]#get the class name from the stack
        #now you both have the ClassName and the func object,so you can
populate your list
        return func#return the decorated function
[/code]
it use the module inspect,to inspect the stack.




More information about the Python-list mailing list