e0d9cf67358f14f2ed23b1b741775f8b0eaf2ad8
[indico-PayWay] / MaKaC / plugins / EPayment / payWay / webinterface / wcomponents.py
1 # -*- coding: utf-8 -*-
2 ##
3 ##
4 ## This file is part of Indico.
5 ## Copyright (C) 2002 - 2014 European Organization for Nuclear Research (CERN).
6 ##
7 ## Indico is free software; you can redistribute it and/or
8 ## modify it under the terms of the GNU General Public License as
9 ## published by the Free Software Foundation; either version 3 of the
10 ## License, or (at your option) any later version.
11 ##
12 ## Indico is distributed in the hope that it will be useful, but
13 ## WITHOUT ANY WARRANTY; without even the implied warranty of
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 ## General Public License for more details.
16 ##
17 ## You should have received a copy of the GNU General Public License
18 ## along with Indico;if not, see <http://www.gnu.org/licenses/>.
19
20 from MaKaC.webinterface import wcomponents
21 import os
22 import pkg_resources
23 import MaKaC.common.Configuration as Configuration
24
25 from MaKaC.plugins.EPayment import payPal
26
27 class WTemplated(wcomponents.WTemplated):
28
29     def _setTPLFile(self):
30         """Sets the TPL (template) file for the object. It will try to get
31             from the configuration if there's a special TPL file for it and
32             if not it will look for a file called as the class name+".tpl"
33             in the configured TPL directory.
34         """
35         cfg = Configuration.Config.getInstance()
36         dir = pkg_resources.resource_filename(payPal.__name__, "tpls")
37         file = cfg.getTPLFile( self.tplId )
38         if file == "":
39             file = "%s.tpl"%self.tplId
40         self.tplFile = os.path.join(dir, file)
41
42         hfile = self._getSpecificTPL(os.path.join(dir,'chelp'),
43                                      self.tplId,
44                                      extension='wohl')
45
46         self.helpFile = os.path.join(dir,'chelp',hfile)