Skip to content
This repository has been archived by the owner on Mar 8, 2018. It is now read-only.

Commit

Permalink
Correct issue tested with SubclassSearchListTest
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
R. Tyler Ballance committed Dec 26, 2009
1 parent 5b32df4 commit 43d7cbe
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cheetah/Template.py
Expand Up @@ -1549,6 +1549,18 @@ def _compile(self, source=None, file=None, compilerSettings=Unspecified,
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,
Expand Down

0 comments on commit 43d7cbe

Please sign in to comment.