Пример #1
0
    def error(self, errorcode, message='an error occured'):
        if errorcode == 404:
            message = 'Sorry, we were not able to find the requested page.  We have logged this error and will look into it.'
        elif errorcode == 403:
            message = 'Sorry, that page is reserved for administrators.  '
        elif errorcode == 500:
            message = "Sorry, the server encountered an error.  We have logged this error and will look into it."

        message += "<p><pre>" + traceback.format_exc() + "</pre><br></p>"
        self.template_vals.update({'errorcode': errorcode, 'message': message})

        if errorcode > 0:
            self.response.set_status(errorcode)

        #errorfile=getattr(self.blog.theme,'error'+str(errorcode))
        #logging.debug(errorfile)
##		if not errorfile:
##			errorfile=self.blog.theme.error
        errorfile = 'error' + str(errorcode) + ".html"
        try:
            content = micolog_template.render(self.blog.theme, errorfile,
                                              self.template_vals)
        except TemplateDoesNotExist:
            try:
                content = micolog_template.render(self.blog.theme,
                                                  "error.html",
                                                  self.template_vals)
            except TemplateDoesNotExist:
                content = micolog_template.render(self.blog.default_theme,
                                                  "error.html",
                                                  self.template_vals)
        except:
            content = message
        self.response.out.write(content)
Пример #2
0
    def error(self,errorcode,message='an error occured'):
        if errorcode == 404:
            message = 'Sorry, we were not able to find the requested page.  We have logged this error and will look into it.'
        elif errorcode == 403:
            message = 'Sorry, that page is reserved for administrators.  '
        elif errorcode == 500:
            message = "Sorry, the server encountered an error.  We have logged this error and will look into it."

        message+="<p><pre>"+traceback.format_exc()+"</pre><br></p>"
        self.template_vals.update( {'errorcode':errorcode,'message':message})

        if errorcode>0:
            self.response.set_status(errorcode)


        #errorfile=getattr(self.blog.theme,'error'+str(errorcode))
        #logging.debug(errorfile)
##		if not errorfile:
##			errorfile=self.blog.theme.error
        errorfile='error'+str(errorcode)+".html"
        try:
            content=micolog_template.render(self.blog.theme,errorfile, self.template_vals)
        except TemplateDoesNotExist:
            try:
                content=micolog_template.render(self.blog.theme,"error.html", self.template_vals)
            except TemplateDoesNotExist:
                content=micolog_template.render(self.blog.default_theme,"error.html", self.template_vals)
        except:
            content=message
        self.response.out.write(unicode(content))
Пример #3
0
	def get_render(self,template_file,values):
		template_file=template_file+".html"
		self.template_vals.update(values)

		try:
			#sfile=getattr(self.blog.theme, template_file)
			logging.debug("get_render:"+template_file)
			html = micolog_template.render(self.blog.theme, template_file, self.template_vals)
		except TemplateDoesNotExist:
			#sfile=getattr(self.blog.default_theme, template_file)
			html = micolog_template.render(self.blog.default_theme, template_file, self.template_vals)

		return html
Пример #4
0
	def get_render(self,template_file,values):
		template_file=template_file+".html"
		self.template_vals.update(values)

		try:
			#sfile=getattr(self.blog.theme, template_file)
			logging.debug("get_render:"+template_file)
			html = micolog_template.render(self.blog.theme, template_file, self.template_vals)
		except TemplateDoesNotExist:
			#sfile=getattr(self.blog.default_theme, template_file)
			html = micolog_template.render(self.blog.default_theme, template_file, self.template_vals)

		return html
Пример #5
0
 def render2(self, template_file, template_vals={}):
     """
     Helper method to render the appropriate template
     """
     self.template_vals.update(template_vals)
     #path = os.path.join(os.path.dirname(__file__), template_file)
     name = template_file.split('/')[-1]
     self.response.out.write(
         unicode(
             micolog_template.render(self.blog.admin_theme, name,
                                     self.template_vals)))