[lib/impression, intranet/impression] stripping trailing whitespaces
Ignore-this: a462d23b95fcfc99372f15a2dc645851 darcs-hash:20090516013103-bd074-7538108fca4203285f67d9f4adff82ade6c33f62.gz
This commit is contained in:
parent
5f5b832609
commit
fdfd2254d3
6 changed files with 71 additions and 72 deletions
|
@ -1,4 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
from cherrypy.filters.basefilter import BaseFilter
|
||||
import cherrypy, os
|
||||
from Cheetah.Template import Template
|
||||
|
@ -21,16 +21,16 @@ def serverSidePath(self, path):
|
|||
except:
|
||||
pass
|
||||
return root_dir + '/templates/' + path
|
||||
|
||||
|
||||
# on surcharge cette fonction dans la classe Template
|
||||
Template.serverSidePath = serverSidePath
|
||||
|
||||
|
||||
|
||||
##########################
|
||||
# templatesEngine
|
||||
##########################
|
||||
#
|
||||
# Application des templates,
|
||||
#
|
||||
# Application des templates,
|
||||
# avec plein de test chians
|
||||
#
|
||||
class TemplatesFilter(BaseFilter):
|
||||
|
@ -46,8 +46,8 @@ class TemplatesFilter(BaseFilter):
|
|||
def static(truc):
|
||||
return "/static/" + truc
|
||||
return static
|
||||
|
||||
|
||||
|
||||
|
||||
def _getBodyTemplate(self, body):
|
||||
if isinstance(body, dict):
|
||||
if body.has_key('template'):
|
||||
|
@ -58,7 +58,7 @@ class TemplatesFilter(BaseFilter):
|
|||
else:
|
||||
return body['template'] + ".tmpl"
|
||||
return False
|
||||
|
||||
|
||||
def _isStandaloneBody(self, body):
|
||||
if isinstance(body, dict):
|
||||
if body.has_key('standalone'):
|
||||
|
@ -68,14 +68,14 @@ class TemplatesFilter(BaseFilter):
|
|||
else:
|
||||
return True
|
||||
return True
|
||||
|
||||
|
||||
|
||||
def _getBodyNameSpace(self, body):
|
||||
if isinstance(body, dict):
|
||||
if body.has_key('values'):
|
||||
return body['values']
|
||||
return {}
|
||||
|
||||
|
||||
def _useMainTemplate(self, body):
|
||||
values = {'environment':cherrypy.config.configMap["global"]["server.environment"],
|
||||
'static':self._getCorrectStaticMethod(),
|
||||
|
@ -84,9 +84,9 @@ class TemplatesFilter(BaseFilter):
|
|||
t = Template(file='main.tmpl', searchList= [body,{'login':cherrypy.session['uid']}, values])
|
||||
except:
|
||||
t = Template(file='main.tmpl', searchList=[body,{'login':''},values])
|
||||
|
||||
|
||||
return t.__str__()
|
||||
|
||||
|
||||
def goWithThisDict(self, aDict):
|
||||
body = aDict
|
||||
bodyTemplate = self._getBodyTemplate(body)
|
||||
|
@ -95,17 +95,17 @@ class TemplatesFilter(BaseFilter):
|
|||
defaultvalues = {'static':self._getCorrectStaticMethod()}
|
||||
t = Template(file=bodyTemplate, searchList=[templatevalues, defaultvalues])
|
||||
body['page'] = t.__str__()
|
||||
|
||||
|
||||
if not self._isStandaloneBody(body):
|
||||
body = self._useMainTemplate(body)
|
||||
else:
|
||||
body = body["page"]
|
||||
body.encode("utf8")
|
||||
cherrypy.response.body = body
|
||||
|
||||
|
||||
|
||||
|
||||
def beforeFinalize(self):
|
||||
|
||||
|
||||
body = cherrypy.response.body
|
||||
if isinstance(body, dict):
|
||||
self.goWithThisDict(body)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue