def _json_global_vars(self):
   return {
     u'raw_uri' : self.request.uri,
     u'parsed_uri' : self.parsed_uri,
     u'is_admin' :  auth.is_current_user_admin(),
     u'debug' :  utils.is_debug()
   }
 def log_exception(self, ex):
   lines = ''.join(traceback.format_exception(*sys.exc_info()))
   if isinstance(ex, urlfetch.DownloadError) or \
     isinstance(ex, DeadlineExceededError) or \
     isinstance(ex, taskqueue.TransientError):
     utils.log.warn(lines)
   else:
     utils.log.error(lines)
     if not utils.is_local() and not utils.is_debug():
       mail.send_mail(
         sender=u'*****@*****.**',
         to=u'*****@*****.**',
         subject=u'Caught Exception',
         body=lines)
  def handle_exception(self, ex):
    if isinstance(ex, exc.HTTPException):
      error_code = ex.code
    else:
      if utils.is_debug() or auth.is_current_user_admin():
        error_code = 500
      else:
        error_code = 404

    self.error(error_code)

    #log the exception
    self.log_exception(ex)

    return self.respond_on_error(error_code)
Example #4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys, os

current_path = os.path.abspath(os.path.dirname(__file__))
sys.path.append(os.path.join(current_path, u'bolognium/lib'))
sys.path.append(os.path.join(current_path, u'bolognium/ext'))

from bolognium.ext import db as db
from bolognium.ext import utils as utils
from bolognium.ext import auth as auth
from bolognium.ext import webapp as webapp
from bolognium.ext import router as router

db.setup_models()

application = webapp.WSGIApplication(router.load_route_map(), 
  debug=utils.is_debug())