goa/test/data/views.py
changeset 6366 1806148d6ce8
parent 6333 e3994fcc21c3
parent 6365 a15cc5e16178
child 6367 d4c485ec1ca1
equal deleted inserted replaced
6333:e3994fcc21c3 6366:1806148d6ce8
     1 # -*- coding: utf-8 -*-
       
     2 # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
       
     3 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
       
     4 #
       
     5 # This file is part of CubicWeb.
       
     6 #
       
     7 # CubicWeb is free software: you can redistribute it and/or modify it under the
       
     8 # terms of the GNU Lesser General Public License as published by the Free
       
     9 # Software Foundation, either version 2.1 of the License, or (at your option)
       
    10 # any later version.
       
    11 #
       
    12 # CubicWeb is distributed in the hope that it will be useful, but WITHOUT
       
    13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
       
    14 # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
       
    15 # details.
       
    16 #
       
    17 # You should have received a copy of the GNU Lesser General Public License along
       
    18 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
       
    19 """
       
    20 
       
    21 """
       
    22 import os
       
    23 os.environ["DJANGO_SETTINGS_MODULE"] = 'data.settings'
       
    24 
       
    25 from django import template
       
    26 
       
    27 
       
    28 def encode_output(self, output):
       
    29     # Check type so that we don't run str() on a Unicode object
       
    30     if not isinstance(output, basestring):
       
    31         return unicode(output)
       
    32     return output
       
    33 
       
    34 template.VariableNode.encode_output = encode_output
       
    35 
       
    36 from cubicweb.view import StartupView
       
    37 
       
    38 INDEX_TEMPLATE = template.Template(u'''
       
    39  <h1>hellĂ´ {{ user.login }}</h1>
       
    40 ''')
       
    41 
       
    42 class MyIndex(StartupView):
       
    43     id = 'index'
       
    44 
       
    45     def call(self):
       
    46         ctx = template.Context({'user': self.req.user})
       
    47         return INDEX_TEMPLATE.render(ctx)