summaryrefslogtreecommitdiffstats
path: root/src/util/page.py
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2013-12-18 22:44:25 -0500
committerSimo Sorce <simo@redhat.com>2013-12-18 23:05:57 -0500
commitee0d1ce71d1f4883aecc426595ac86322a91260e (patch)
treed3f068d9bca5ef9ead0ca77ab3a5ae4c25c1cfbf /src/util/page.py
parent13a58ef5cb599d3e8e3a9484bd84fa6fae3f3390 (diff)
downloadipsilon-ee0d1ce71d1f4883aecc426595ac86322a91260e.tar.gz
ipsilon-ee0d1ce71d1f4883aecc426595ac86322a91260e.tar.xz
ipsilon-ee0d1ce71d1f4883aecc426595ac86322a91260e.zip
Move template and user retrieval to page class
Signed-off-by: Simo Sorce <simo@redhat.com>
Diffstat (limited to 'src/util/page.py')
-rwxr-xr-xsrc/util/page.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/util/page.py b/src/util/page.py
index 4236e9f..15cbed0 100755
--- a/src/util/page.py
+++ b/src/util/page.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+from util import user
import cherrypy
def protect():
@@ -31,10 +32,12 @@ def protect():
class Page(object):
def __init__(self, template_env):
self._env = template_env
+ self.basepath = cherrypy.config.get('base.mount', "")
self.username = None
def __call__(self, *args, **kwargs):
self.username = cherrypy.session.get('user', None)
+ self.user = user.User(self.username)
if len(args) > 0:
op = getattr(self, args[0], None)
@@ -47,6 +50,10 @@ class Page(object):
return self.default(*args, **kwargs)
+ def _template(self, *args, **kwargs):
+ t = self._env.get_template(args[0])
+ return t.render(basepath=self.basepath, user=self.user, **kwargs)
+
def default(self, *args, **kwargs):
raise cherrypy.HTTPError(404)