def _process(self): try: # regenerate file is needed self._dict["__rh__"] = self self._dict["user"] = None data = templateEngine.render(self._tplFile, self._dict).strip() with open(self._cacheFile, "w") as fp: fp.write(data) except Exception: Logger.get('vars_js').exception('Problem generating vars.js') raise
def _process(self): try: # regenerate file is needed self._dict["__rh__"] = self self._dict["user"] = None self._htmlData = templateEngine.render(self._tplFile, self._dict) fh = open(self._htmlPath, "w") fh.write(self._htmlData) fh.close() self._setHeaders() except Exception, e: Logger.get('vars_js').exception('Problem generating vars.js') return 'indicoError: %s' % e
def _process( self ): try: # regenerate file is needed self._dict["__rh__"] = self self._dict["user"] = None self._htmlData = templateEngine.render(self._tplFile, self._dict) fh = open(self._htmlPath, "w") fh.write(self._htmlData) fh.close() self._setHeaders() except Exception, e: Logger.get('vars_js').exception('Problem generating vars.js') return 'indicoError: %s' % e
def getHTML(self, params=None): """Returns the HTML resulting of formating the text contained in the corresponding TPL file with the variables returned by the getVars method. Params: params -- additional paramters received from the caller """ self._rh = ContextManager.get('currentRH', None) if self.tplId == None: self.tplId = self.__class__.__name__[1:] self._setTPLFile() self.__params = {} if params != None: self.__params = params # include context help info, if it exists helpText = None if os.path.exists(self.helpFile): try: fh = open(self.helpFile, "r") helpText = fh.read() fh.close() except exceptions.IOError: pass vars = self.getVars() vars['__rh__'] = self._rh vars['self_'] = self tempHTML = templateEngine.render(self.tplFile, vars, self) if helpText == None: return tempHTML else: try: return ContextHelp().merge(self.tplId, tempHTML, helpText) except etree.LxmlError, e: if tempHTML.strip() == '': raise MaKaCError( _("Template " + str(self.tplId) + " produced empty output, and it has a .wohl file. Error: " + str(e))) else: raise
def getHTML( self, params=None ): """Returns the HTML resulting of formating the text contained in the corresponding TPL file with the variables returned by the getVars method. Params: params -- additional paramters received from the caller """ self._rh = ContextManager.get('currentRH', None) if self.tplId == None: self.tplId = self.__class__.__name__[1:] self._setTPLFile() self.__params = {} if params != None: self.__params = params # include context help info, if it exists helpText = None if os.path.exists(self.helpFile): try: fh = open( self.helpFile, "r") helpText = fh.read() fh.close() except exceptions.IOError: pass vars = self.getVars() vars['__rh__'] = self._rh vars['self_'] = self tempHTML = templateEngine.render(self.tplFile, vars, self) if helpText == None: return tempHTML else: try: return ContextHelp().merge(self.tplId, tempHTML, helpText) except etree.LxmlError, e: if tempHTML.strip() == '': raise MaKaCError(_("Template " + str(self.tplId) + " produced empty output, and it has a .wohl file. Error: " + str(e))) else: raise