Exemplo n.º 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)
Exemplo n.º 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))
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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)))