Changes between Version 12 and Version 13 of ShortcutSyntaxIdeas


Ignore:
Timestamp:
09/21/05 14:30:49 (10 years ago)
Author:
brantley (deadwisdom@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ShortcutSyntaxIdeas

    v12 v13  
    9696=== Idea 1 ===
    9797
    98 This satisfies the complicated and simplistic decorator, return or yield.
     98This satisfies the complicated and simplistic decorator, return or yield. 
     99Also, you can now change the template or context used, by yielding them, e.g. "yield {'template': 'primes/index'}".
    99100
    100101It goes in django.views.decorators.shortcuts:
     
    102103{{{
    103104#!python
    104 def page(template, context=None, **decorator_args):
     105def page(template=None, context=None, **decorator_args):
    105106    def _wrapper(fn):
    106107        def _innerWrapper(request, **args):
     
    116117                else:
    117118                    context_dict.update(i)
     119            template = context_dict.get("template", template)
     120            context = context_dict.get("context", context)
    118121            return load_and_render(template, context_dict, context)
    119122           
Back to Top