# -*- coding: utf-8 -*-
import logging

from pylons import url, session, tmpl_context as c
from pylons.controllers.util import abort, redirect_to
from pylons.i18n import set_lang, get_lang, _, ungettext, N_

from {{package}}.lib.base import BaseController, render

log = logging.getLogger(__name__)

from {{package}} import model as model
from {{package}}.lib.decorators import authorize
from {{package}}.lib.auth.permissions import SignedIn

class TestingController(BaseController):

    # Need to protect an entire controller?
    # Decorating __before__ protect all actions
    # @authorize(SignedIn())
    def __before__(self):
        pass

    def index(self):
        c.users = model.Session.query(model.User).all()
        c.groups = model.Session.query(model.Group).all()
        c.permissions = model.Session.query(model.Permission).all()
        c.title = 'Test'
        return render('test.mak')

    # Need to protect just a single action?
    # Do it like this ....
    @authorize(SignedIn())
    def privindex(self):
        c.users = model.Session.query(model.User).all()
        c.groups = model.Session.query(model.Group).all()
        c.permissions = model.Session.query(model.Permission).all()
        c.title = 'Test'
        return render('test.mak')
