Example #1
0
 def revert_template(self,
                     templateName,
                     format="json",
                     requestOrigin="",
                     **kwargs):
     user, sMessages, fMessages, config, templateText = (
         cherrypy.session.get("user"), [], [],
         cherrypy.request.app.config['filelocker'], None)
     if requestOrigin != cherrypy.session['request-origin']:
         fMessages.append("Missing request key!!")
     else:
         try:
             templateName = strip_tags(templateName)
             filePath = os.path.join(config['vault'], "custom",
                                     templateName)
             if os.path.exists(
                     filePath
             ):  #This causes no problems if the tempate doesn't already exist
                 os.remove(filePath)
             templateFile = open(get_template_file(templateName))
             templateText = templateFile.read()
             sMessages.append(
                 "Successfully reverted template file %s to original." %
                 templateName)
         except Exception, e:
             cherrypy.log.error(
                 "[%s] [revert_template] [Unable to revert template text: %s]"
                 % (user.id, str(e)))
             fMessages.append("Unable to revert template text: %s" % str(e))
Example #2
0
 def save_template(self,
                   templateName,
                   templateText,
                   format="json",
                   requestOrigin="",
                   **kwargs):
     user, sMessages, fMessages, config = (
         cherrypy.session.get("user"), [], [],
         cherrypy.request.app.config['filelocker'])
     if requestOrigin != cherrypy.session['request-origin']:
         fMessages.append("Missing request key!!")
     else:
         try:
             templateName = strip_tags(templateName)
             filePath = os.path.join(config['vault'], "custom",
                                     templateName)
             if not os.path.exists(os.path.join(config['vault'], "custom")):
                 os.mkdir(os.path.join(config['vault'], "custom"))
             templateFile = open(filePath, "w")
             templateFile.write(templateText)
             templateFile.close()
             sMessages.append("Successfully saved custom template file")
             templateFile = open(get_template_file(templateName))
             templateText = templateFile.read()
         except Exception, e:
             cherrypy.log.error(
                 "[%s] [save_template] [Unable to save template text: %s]" %
                 (user.id, str(e)))
             fMessages.append("Unable to save template text: %s" % str(e))
Example #3
0
 def get_template_text(self, templateName, format="json", **kwargs):
     user, sMessages, fMessages, templateText = (cherrypy.session.get("user"), [], [], "")
     try:
         templateName = strip_tags(templateName)
         templateFilePath = get_template_file(templateName)
         templateFile = open(templateFilePath)
         templateText = templateFile.read()
     except Exception, e:
         cherrypy.log.error("[%s] [get_template_text] [Unable to load template text: %s]" % (user.id, str(e)))
         fMessages.append("Unable to load template text: %s" % str(e))
 def get_template_text(self, templateName, format="json", **kwargs):
     user, sMessages, fMessages, templateText = (cherrypy.session.get("user"), [], [], "")
     try:
         templateName = strip_tags(templateName)
         templateFilePath = get_template_file(templateName)
         templateFile = open(templateFilePath)
         templateText = templateFile.read()
     except Exception, e:
         cherrypy.log.error("[%s] [get_template_text] [Unable to load template text: %s]" % (user.id, str(e)))
         fMessages.append("Unable to load template text: %s" % str(e))
Example #5
0
 def revert_template(self, templateName, format="json", requestOrigin="", **kwargs):
     user, sMessages, fMessages, config, templateText = (cherrypy.session.get("user"), [], [], cherrypy.request.app.config['filelocker'], None)
     if requestOrigin != cherrypy.session['request-origin']:
         fMessages.append("Missing request key!!")
     else:
         try:
             templateName = strip_tags(templateName)
             filePath = os.path.join(config['vault'], "custom", templateName)
             if os.path.exists(filePath): #This causes no problems if the tempate doesn't already exist
                 os.remove(filePath)
             templateFile = open(get_template_file(templateName))
             templateText = templateFile.read()
             sMessages.append("Successfully reverted template file %s to original." % templateName)
         except Exception, e:
             cherrypy.log.error("[%s] [revert_template] [Unable to revert template text: %s]" % (user.id, str(e)))
             fMessages.append("Unable to revert template text: %s" % str(e))
Example #6
0
 def save_template(self, templateName, templateText, format="json", requestOrigin="", **kwargs):
     user, sMessages, fMessages, config = (cherrypy.session.get("user"), [], [], cherrypy.request.app.config['filelocker'])
     if requestOrigin != cherrypy.session['request-origin']:
         fMessages.append("Missing request key!!")
     else:
         try:
             templateName = strip_tags(templateName)
             filePath = os.path.join(config['vault'], "custom", templateName)
             if not os.path.exists(os.path.join(config['vault'], "custom")):
                 os.mkdir(os.path.join(config['vault'], "custom"))
             templateFile = open(filePath, "w")
             templateFile.write(templateText)
             templateFile.close()
             sMessages.append("Successfully saved custom template file")
             templateFile = open(get_template_file(templateName))
             templateText = templateFile.read()
         except Exception, e:
             cherrypy.log.error("[%s] [save_template] [Unable to save template text: %s]" % (user.id, str(e)))
             fMessages.append("Unable to save template text: %s" % str(e))