Changes between Version 10 and Version 11 of ShortcutSyntaxIdeas


Ignore:
Timestamp:
09/21/2005 02:22:13 PM (10 years ago)
Author:
brantley (deadwisdom@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ShortcutSyntaxIdeas

    v10 v11  
    9696=== Idea 1 ===
    9797
     98This satisfies the complicated and simplistic decorator, return or yield.
    9899This goes in django.views.decorators.shortcuts:
    99100
     
    103104    def _wrapper(fn):
    104105        def _innerWrapper(request, **args):
    105             for i in fn(request, **args):
    106                 if isinstance(i, httpwrappers.HttpResponse):
     106            context_dict = decorator_args.copy()
     107            g = fn(request, **args)
     108            if not hasattr(g, 'next'):  #Is this a generator?  Otherwise make her a tuple!
     109                g = (g,)
     110            for i in g:
     111                if isinstance(i, HttpResponse):
    107112                    return i
    108113                if type(i) == type(()):
    109114                    context_dict[i[0]] = i[1]
    110115                else:
    111                     context_dict.update(i)           
    112             return load_and_render(template, context_dict, context=context)
     116                    context_dict.update(i)
     117            return load_and_render(template, context_dict, context)
    113118           
    114119        return _innerWrapper
Back to Top