1 from django.shortcuts import render
2 from ssify import ssi_included, ssi_expect, SsiVariable as V
5 @ssi_included(use_lang=False, get_ssi_vars=lambda number: [
6 ('test_tags.number_of_quotes',),
7 ('test_tags.quote_len_odd', (ssi_expect(number, int),))
9 def quote(request, number):
11 return render(request, 'tests/quote.html', {
13 'quote': QUOTES[number]
17 @ssi_included(use_lang=False, get_ssi_vars=lambda: (
18 lambda number: [number] + quote.get_ssi_vars(number))(
19 number=V('test_tags.random_number', [V('test_tags.number_of_quotes')])
21 def random_quote(request):
23 This view is purposely overcomplicated to test interdependencies
24 between SSI variables and SSI includes.
26 It finds number of quotes and sets that in an SSI variable,
27 then uses that to set a random quote number in a second variable,
28 then sets a third saying if the length of the selected quote is odd.
31 return render(request, 'tests/random_quote.html')
34 # Nothing interesting here.
38 stdout_backup = sys.stdout
39 sys.stdout = cStringIO.StringIO()
41 this_string = sys.stdout.getvalue()
43 sys.stdout = stdout_backup
44 return this_string.split('\n')