Changes between Version 10 and Version 11 of ShortcutSyntaxIdeas
- Timestamp:
- Sep 21, 2005, 2:22:13 PM (19 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ShortcutSyntaxIdeas
v10 v11 96 96 === Idea 1 === 97 97 98 This satisfies the complicated and simplistic decorator, return or yield. 98 99 This goes in django.views.decorators.shortcuts: 99 100 … … 103 104 def _wrapper(fn): 104 105 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): 107 112 return i 108 113 if type(i) == type(()): 109 114 context_dict[i[0]] = i[1] 110 115 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) 113 118 114 119 return _innerWrapper