Cherrypy @AutoRender magic

from functools import wraps

def AutoRender(f):
    
    name =  f.__name__
    f.exposed = True
    #raise Exception([ name, [(k, getattr(f,k),"\n",) for k in dir(f)]])
    
    @wraps(f)
    def wrapper(self, *args, **kwargs):
        cls = self.__class__.__name__.lower()
        result = f(self, *args, **kwargs)
        pathname = "%s/%s" % (cls, name, )
        
        return Render(pathname , result ).gen()
        
    
    wrapper.exposed = True
    return wrapper

I often find it tedious in pretty much any language to have the following pattern:

   Class MyController:
        
         def action(self):
             result = do_stuff()
             return Render("MyController/action", { result : result } )
         action.exposed = True

So with @AutoRender it assumes the above pattern to make things a little cleaner @ the application layer

class MyController:
      
      @AutoRender
      def action(self):
          result = do_stuff()
          return { result: result }

As much as Ruby annoys me with its syrupy breakfast cereal syntactic sugar, I do praise it for laying down an assortment of helpers and shortcuts for common tasks.