diff options
author | R. Tyler Ballance <tyler@monkeypox.org> | 2009-12-26 14:31:09 -0800 |
---|---|---|
committer | R. Tyler Ballance <tyler@monkeypox.org> | 2009-12-26 14:31:09 -0800 |
commit | 43d7cbe361a3fe73dc20337e544144b8c7c0d7d2 (patch) | |
tree | 36e10a42709dccd645a4f5cf766910d8ddef406b | |
parent | 5b32df45da4202f6bcd1465cc8ffcb640c55956f (diff) | |
download | python-cheetah-43d7cbe361a3fe73dc20337e544144b8c7c0d7d2.tar.gz |
Correct issue tested with SubclassSearchListTest
Subclasses (in Python) of Template failed to properly
propogate attributes into the dyanmically compiled templates
that were created with them as per:
http://www.cheetahtemplate.org/docs/users_guide_html_multipage/gettingStarted.tutorial.html
Issue reported by dhaivat.
-rw-r--r-- | cheetah/Template.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/cheetah/Template.py b/cheetah/Template.py index 0eba725..c76f305 100644 --- a/cheetah/Template.py +++ b/cheetah/Template.py @@ -1549,6 +1549,18 @@ class Template(Servlet): mainMethodName=mainMethodName, compilerSettings=compilerSettings, keepRefToGeneratedCode=True) + + if not self.__class__ == Template: + # Only propogate attributes if we're in a subclass of + # Template + for k, v in self.__class__.__dict__.iteritems(): + if not v or k.startswith('__'): + continue + ## Propogate the class attributes to the instance + ## since we're about to obliterate self.__class__ + ## (see: cheetah.Tests.Tepmlate.SubclassSearchListTest) + setattr(self, k, v) + self.__class__ = templateClass # must initialize it so instance attributes are accessible templateClass.__init__(self, |