def _decorator(self,
                   name=None,
                   template=None,
                   key=None,
                   timeout=DEFAULT_TIMEOUT,
                   using=None,
                   cached=True):
        """
        Handles both decorator pointer and caller (with or without arguments).
        Creates a Viewlet instance to wrap the decorated function with.
        """
        from viewlet.models import Viewlet

        if isinstance(name, types.FunctionType):

            def declare(func):
                viewlet = Viewlet(self)
                return viewlet.register(func)

            return declare(name)
        else:
            viewlet = Viewlet(self,
                              name=name,
                              template=template,
                              key=key,
                              timeout=timeout,
                              using=using,
                              cached=cached)
            return viewlet.register
Beispiel #2
0
 def declare(func):
     viewlet = Viewlet(self)
     return viewlet.register(func)