~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to turbozpt/template.py

clean up dusty parts of turbozpt

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
"""
2
 
By VladDrac@irc.freenode.net/#turbogears
3
 
+ Some small modifications
4
2
"""
5
3
 
6
4
from zope.pagetemplate import pagetemplatefile
7
 
import os.path
8
 
import sys
 
5
import os
9
6
 
10
7
_zpt_cache = {}
11
8
 
32
29
        self.options = options
33
30
 
34
31
    def __getitem__(self, name):
35
 
        tpl = zpt(os.path.join(self.base, name))
36
 
        return tpl(**self.options)
 
32
        return zpt(os.path.join(self.base, name))(**self.options)
37
33
 
38
34
class PageTemplate(pagetemplatefile.PageTemplateFile):
39
35
    def __init__(self, name):
40
 
        base = os.path.dirname(sys._getframe(1).f_globals["__file__"])
41
 
        self.name = name
42
 
        self.fullpath = os.path.join(base, self.name)
43
 
        self.base = os.path.dirname(self.fullpath)
44
 
        pagetemplatefile.PageTemplateFile.__init__(self, self.fullpath)
 
36
        self.base = os.path.dirname(name)
 
37
        pagetemplatefile.PageTemplateFile.__init__(self, name)
45
38
 
46
39
    def pt_getContext(self, args=(), options={}, **ignored):
47
 
        rval = pagetemplatefile.PageTemplateFile.pt_getContext(self, args, options, **ignored)
48
 
        rval.update(options)
49
 
        rval.update({'here':Here(self.base, options), 'template':self})
 
40
        rval = pagetemplatefile.PageTemplateFile.pt_getContext(
 
41
            self, args, options, **ignored)
 
42
        rval.update(options)
 
43
        rval.update({'here':Here(self.base, options)})
50
44
        return rval