Bug with Template subclassing

Gunter Ohrner <[email protected]> Wed, 30 Jul 2014 16:24:45 +0200
Newsgroups gmane.comp.python.cheetah
Organization Gunter Ohrner Datensysteme
Message-ID <[email protected]>
Hi everyone!

I've no idea if Cheetah is still actively maintained, but as I've just 
spend lots of hours trying to understand why one of our websites would 
not work on my development machine, I'm summarising my findings here for 
completeness' sake...

Either I'm doing something totally wrong, or a major bug was introduced 
in 2009 in the following commit:

https://github.com/rtyler/cheetah/commit/43d7cbe361a3fe73dc20337e544144b8c7c0d7d2

Our site uses dynamically compiled templates with a custom Template-
subclass which overwrites the serverSidePath method:


class TestcaseTemplate( Template ):
  def __init__(self, *args, **kwargs):
    Template.__init__(self, *args, **kwargs)

  def serverSidePath(self, path=None,
                     normpath=os.path.normpath,
                     abspath=os.path.abspath):

    ## Do something funky here...

    return Template.serverSidePath(self, path, normpath, abspath)


The code added in the abovementioned commit now causes the Template 
class to replace the bound method serverSidePath by an unbound method, 
ie. effectively a function.

This causes subsequent calls of  
templateObject.serverSidePath(stringPath) to pass the value of 
"stringPath" as "self" instead of "path", with no way to access the 
object instance.

The commit references above effectively at least breaks all methods 
defined in the subclass of Template...

Hopefully this report will safe someone elses time, and reprieve him/her 
from pulling his hair out like I did... ;)

Take care,

  Gunter


------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls. 
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk