Esempio n. 1
0
 def register_user(self):
     """Register a new user and an assign them a list. Send an email
     notification to site admins.
     """
     user = g.User.create(email=self.email.data, password=self.password.data)
     todo_list = g.List.create(user)
     mail_admins("A new user registered",
                 "The user's email was {0}.".format(user.email))
     return user
Esempio n. 2
0
    def emit(self, record):
        if record.exc_info:
            exc_info = record.exc_info
            stack_trace = '\n'.join(traceback.format_exception(*record.exc_info))
        else:
            exc_info = "No execution info supplied"
            stack_trace = "No stack trace info supplied"
        subject = "Error - {exc_type}".format(**{'app_name': self.app.import_name,
                                                 'exc_type': exc_info[0]})
        message = stack_trace + "\n"
        message += "*" * 40
        message += "\n"

        # Get request information
        for attr in ['method', 'path', 'url', 'form', 'args']:
            message += "{0}: {1}\n".format(attr, getattr(request, attr, None))
        message += "User: {0}".format(g.user)

        mail_admins(subject, message)