From 43d7cbe361a3fe73dc20337e544144b8c7c0d7d2 Mon Sep 17 00:00:00 2001 From: "R. Tyler Ballance" Date: Sat, 26 Dec 2009 14:31:09 -0800 Subject: 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. --- cheetah/Template.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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, -- cgit v1.2.1