Changes between Version 14 and Version 15 of ShortcutSyntaxIdeas


Ignore:
Timestamp:
Sep 21, 2005, 9:52:33 PM (19 years ago)
Author:
anonymous
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ShortcutSyntaxIdeas

    v14 v15  
    9292}}}
    9393
     94== Idea 5: Class plus decorator ==
     95{{{
     96#!python
     97from django.views.decorators.shortcuts import use_template
     98
     99class AClass(BaseClass):
     100    #class level attributes here (e.g. for the menu generation - see below)
     101
     102    @use_template('primes/index')
     103    def prime_index(request):
     104        return {
     105            'title': 'Page Title',
     106            'primes': [2, 3, 5, 7],
     107            'header': 'The first 4 primes'
     108        }
     109}}}
     110
     111If i dynamically build a menu, etc. I would like to be able to define that at the class level so that I don't have to repeat myself in every method, or repeat myself decorating every method.  I'm kind of new to python and am not familiar with all its capabilities so my example may not be the best.
     112
    94113== Implementations ==
    95114
Back to Top