from MaKaC.webinterface import wcomponents
import os
import MaKaC.common.Configuration as Configuration
from copy import copy

from MaKaC.plugins.EPayment import payPal

class WTemplated(wcomponents.WTemplated):
    
    def __setTPLFile(self):
        """Sets the TPL (template) file for the object. It will try to get
            from the configuration if there's a special TPL file for it and
            if not it will look for a file called as the class name+".tpl"
            in the configured TPL directory.
        """
        cfg = Configuration.Config.getInstance()
        
        dir = os.path.join(payPal.__path__[0], "tpls")
        file = cfg.getTPLFile( self.tplId )
        if file == "":
            file = "%s.tpl"%self.tplId
        self.tplFile = os.path.join(dir, file)