comparison roundup/cgi/engine_zopetal.py @ 4740:fe9568a6cbd6

Untangle template selection logic from template loading functionality.
author anatoly techtonik <techtonik@gmail.com>
date Tue, 15 Jan 2013 00:10:01 +0300
parents 94be76e04140
children 0421390b3094
comparison
equal deleted inserted replaced
4739:94be76e04140 4740:fe9568a6cbd6
6 import errno 6 import errno
7 import mimetypes 7 import mimetypes
8 import os 8 import os
9 import os.path 9 import os.path
10 10
11 from roundup.cgi.templating import StringIO, context, translationService, find_template, LoaderBase 11 from roundup.cgi.templating import StringIO, context, translationService, LoaderBase
12 from roundup.cgi.PageTemplates import PageTemplate, GlobalTranslationService 12 from roundup.cgi.PageTemplates import PageTemplate, GlobalTranslationService
13 from roundup.cgi.PageTemplates.Expressions import getEngine 13 from roundup.cgi.PageTemplates.Expressions import getEngine
14 from roundup.cgi.TAL import TALInterpreter 14 from roundup.cgi.TAL import TALInterpreter
15 15
16 GlobalTranslationService.setGlobalTranslationService(translationService) 16 GlobalTranslationService.setGlobalTranslationService(translationService)
19 templates = {} 19 templates = {}
20 20
21 def __init__(self, dir): 21 def __init__(self, dir):
22 self.dir = dir 22 self.dir = dir
23 23
24 def load(self, name, view=None): 24 def check(self, name):
25 for extension in ['', '.html', '.xml']:
26 f = name + extension
27 src = os.path.join(self.dir, f)
28 if os.path.exists(src):
29 return (src, f)
30
31 def load(self, tplname):
25 # find the source 32 # find the source
26 src, filename = find_template(self.dir, name, view) 33 src, filename = self.check(tplname)
27 34
28 # has it changed? 35 # has it changed?
29 try: 36 try:
30 stime = os.stat(src)[os.path.stat.ST_MTIME] 37 stime = os.stat(src)[os.path.stat.ST_MTIME]
31 except os.error, error: 38 except os.error, error:

Roundup Issue Tracker: http://roundup-tracker.org/