File: kidTemplate.py

package info (click to toggle)
okasha 0.2.4-4
  • links: PTS, VCS
  • area: non-free
  • in suites: bullseye, sid
  • size: 856 kB
  • sloc: python: 1,092; sh: 29; makefile: 7
file content (35 lines) | stat: -rw-r--r-- 1,155 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- coding: UTF-8 -*-
"""
Okasha - a very simple WSGI webframe work
Copyright © 2009, Muayyad Alsadi <alsadi@ojuba.org>

    Released under terms of Waqf Public License.
    This program is free software; you can redistribute it and/or modify
    it under the terms of the latest version Waqf Public License as
    published by Ojuba.org.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    The Latest version of the license can be found on
    "http://waqf.ojuba.org/license"

"""
import sys, os, os.path
import kid
from .baseWebApp import fileNotFoundException
#from utils import ObjectsCache # kid has its own cache

def kidTemplate(rq, o, bfn=None, **kw):
  fn=rq.webapp._getTemplateFile(bfn, default="root.kid")
  try: tmp=kid.load_template(file=fn)
  except kid.template_util.TemplateNotFound: raise fileNotFoundException()
  except:
    rq.webapp._logger.debug('template error fn=[%s]' % fn)
    raise
  # FIXME: check for valid template
  o.update(kw)
  s=tmp.Template(**o).serialize()
  return s