#!/usr/bin/env python
# show python where the web modules are
import sys
sys.path.append('../')
sys.path.append('../../../') 
def handler(dict, params={}):
    p = {
        'email':None,
        'message':"""
                       
An Error Occured
                       An Error Occured
                       The devlopers have been informed
                    """,
        'reply':'Website Error '
    }
    for k,v in params.items():
        p[k] = v
    
    if not p.has_key('email'):
        raise Exception('You must specify the email parameter.')
        
    import web, web.mail
    web.mail.send(
        msg="There was an exception in the code of the website.\n\n"+dict['text'],
        to=p['email'],
        reply=p['reply'],
        subject='Error in website',
        sendmail='usr/bin/sendmail',
        smtp='smtp.ntlworld.com',
        method='smtp',# could use method='sendmail' to send using sendmail.
    )
    print web.header()
    print p['message']
    
import web.error
web.error.handle(
    handler, 
    email = 'james@example.com',
    message = """
           An Error Occured
           Internal Error
           The devlopers have been informed.
        """,
    reply = 'Developer '
)
raise Exception('This is a test exception')