Exemplo n.º 1
0
    def show(self, req):
        self.url_slug = self.url_slug[:40]
        try:
            jb = JotBit.get(url_slug=self.url_slug)
        except JotBit.NotFound:
            jb = JotBit(url_slug=self.url_slug)
        self.text = jb.text or ''

        return render_view(template="note", data=self.__dict__)
Exemplo n.º 2
0
    def __call__(self, req):
        '''
        The ErrorController will return a formatted stack trace if in debug
        mode, or point to the regular error page otherwise.
        '''
        if project.email_errors or project.debug:
            stack_trace = render_view(template='stack_trace', data={'req': req})

        if project.debug:
            return Response(body=stack_trace, status=self.status_code)
        else:
            return error_response('general_error', self.status_code)
Exemplo n.º 3
0
    def __call__(self, req):
        '''
        The ErrorController will return a formatted stack trace if in debug
        mode, or point to the regular error page otherwise.
        '''
        if project.email_errors or project.debug:
            stack_trace = render_view(template='stack_trace',
                                      data={'req': req})

        if project.debug:
            return Response(body=stack_trace, status=self.status_code)
        else:
            self.template_id = os.path.join('error',
                                            self.error_map[self.status_code])
            return Response(body=self._view(), status=self.status_code)
Exemplo n.º 4
0
def error_response(template="general_error", status_code=500):
    template = os.path.join('error', template)
    return Response(body=render_view(template=template, format="html"),
                            status=status_code)