Cheetah changes: upgrade to Cheetah 2.0 (release candidate 7, looking very

stable at this point). This gives us big improvements to template compilation
and caching, and thus a nice little speed boost.
This commit is contained in:
James Taylor
2007-03-08 17:29:58 +00:00
parent d389d70b5b
commit 4ac180091e
2 changed files with 23 additions and 7 deletions
+1
View File
@@ -28,6 +28,7 @@ class Configuration( object ):
self.test_conf = resolve_path( kwargs.get( "test_conf", "" ), self.root )
self.tool_config = resolve_path( kwargs.get( 'tool_config_file', 'tool_conf.xml' ), self.root )
self.template_path = resolve_path( kwargs.get( "template_path", "templates" ), self.root )
self.template_cache = resolve_path( kwargs.get( "template_cache_path", "database/compiled_templates" ), self.root )
self.job_queue_workers = int( kwargs.get( "job_queue_workers", "10" ) )
self.admin_pass = kwargs.get('admin_pass',"galaxy")
self.sendmail_path = kwargs.get('sendmail_path',"/usr/sbin/sendmail")
+22 -7
View File
@@ -263,19 +263,34 @@ class UniverseWebTransaction( framework.DefaultWebTransaction ):
form.
"""
return self.fill_template( "form.tmpl", form=form )
def compile_and_fill_template( self, source=None, file=None, namespaces=[] ):
"""
Get the template matching `source` or `file` and fill it using
variables from `namespaces`.
"""
tclass = Template.compile( source=source,
file=file,
cacheModuleFilesForTracebacks=True,
cacheDirForModuleFiles=self.app.config.template_cache )
default_namespace = dict( caller=self, t=self, h=webhelpers,
util=util, request=self.request,
response=self.response, app=self.app )
template = tclass( namespaces = namespaces + [ default_namespace ] )
return str( template )
def fill_template(self, file_name, **kwargs):
"""
Fill in a template, putting any keyword arguments on the context.
Fill in a template from a file.
"""
template = Template( file=os.path.join(self.app.config.template_path, file_name),
searchList=[kwargs, self.template_context, dict(caller=self, t=self, h=webhelpers, util=util, request=self.request, response=self.response, app=self.app)] )
return str(template)
return self.compile_and_fill_template(
file = os.path.join( self.app.config.template_path, file_name ),
namespaces=[ kwargs, self.template_context ] )
def fill_template_string(self, template_string, context=None, **kwargs):
"""
Fill in a template, putting any keyword arguments on the context.
Fill in a template from a string.
"""
template = Template( source=template_string, searchList=[context or kwargs, dict(caller=self)] )
return str(template)
return self.compile_and_fill_template(
source = template_string,
namespaces = [ context or kwargs, dict(caller=self) ] )
class FormBuilder( object ):
"""