Skip to content
This repository
Browse code

hide internal variables in web.template.render better

  • Loading branch information...
commit 10b4e17f80bf4212c13557f9f224c8b8caae2d48 1 parent 8e8269d
Aaron Swartz authored

Showing 1 changed file with 11 additions and 11 deletions. Show diff stats Hide diff stats

  1. +11 11 web/template.py
22 web/template.py
@@ -767,37 +767,37 @@ class render:
767 767 def __init__(self, loc='templates/', cache=None, base=None):
768 768 if cache is None:
769 769 cache = not config.get('debug', False)
770   - self.loc = loc
  770 + self._loc = loc
771 771 if cache:
772   - self.cache = {}
  772 + self._cache = {}
773 773 else:
774   - self.cache = False
  774 + self._cache = False
775 775
776   - self.base = base
  776 + self._base = base
777 777
778 778 def _do(self, name, filter=None):
779   - if self.cache is False or name not in self.cache:
  779 + if self._cache is False or name not in self._cache:
780 780
781   - tmplpath = os.path.join(self.loc, name)
  781 + tmplpath = os.path.join(self._loc, name)
782 782 p = [f for f in glob.glob(tmplpath + '.*') if not f.endswith('~')] # skip backup files
783 783 if not p and os.path.isdir(tmplpath):
784   - return render(tmplpath, cache=self.cache)
  784 + return render(tmplpath, cache=self._cache)
785 785 elif not p:
786 786 raise AttributeError, 'no template named ' + name
787 787
788 788 p = p[0]
789 789 c = Template(open(p).read(), filename=p)
790   - if self.cache is not False: self.cache[name] = (p, c)
  790 + if self._cache is not False: self._cache[name] = (p, c)
791 791
792   - if self.cache is not False: p, c = self.cache[name]
  792 + if self._cache is not False: p, c = self._cache[name]
793 793
794 794 if p.endswith('.html') or p.endswith('.xml'):
795 795 if not filter: c.filter = websafe
796 796 return c
797 797
798 798 def __getattr__(self, p):
799   - if self.base:
800   - return lambda *a, **kw: self._do(self.base)(self._do(p)(*a, **kw))
  799 + if self._base:
  800 + return lambda *a, **kw: self._do(self._base)(self._do(p)(*a, **kw))
801 801 else:
802 802 return self._do(p)
803 803

0 comments on commit 10b4e17

Please sign in to comment.
Something went wrong with that request. Please try again.