Exemplo n.º 1
0
 def __call__(self, f, **kwargs):
     env = Environment(loader=FileSystemLoader(self.views_dir))
     template = env.get_template(self.template_name)
     if hasattr(f, '__call__'):
         @wraps(f)
         def decorator(obj, request):
             f(obj, request)#call any lower functions in the decorator chain
             data = object_inspect(obj)
             rendered_template = template.render(data.attrs)
             return HTTPResponse(str(rendered_template))
         return decorator
     data = object_inspect(f)
     for attrname in kwargs:
         data.attrs[attrname] = kwargs[attrname]
     rendered_template = template.render(data.attrs)
     return str(rendered_template)
Exemplo n.º 2
0
 def decorator(obj, request):
     f(obj, request)#call any lower functions in the decorator chain
     data = object_inspect(obj)
     rendered_template = template.render(data.attrs)
     return HTTPResponse(str(rendered_template))