make app "error" with a controller default.py and an action

def index():
    from gluon.tools import Mail
    mail=Mail()
    mail.settings.server="smpt.example.com:port"
    mail.settings.sender="y...@example.com"
    mail.settings.login="you:password"
    ticket=request.vars.ticket
    subject="Ticket: %s" % ticket
    message=bla bla bla
    mail.sent
(to="administra...@example.com",subject=subject,message=message)
    return "Sorry, an error occurred (%s), administrator has been
notified" % ticket

and then create a file web2py/routes.py and in it write:

error_handler = dict(application='error', controller='default',
function='index')





On Sep 10, 8:54 am, David Zejda <d...@atlas.cz> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello,
>
> for a productive site I wish to touch the default error handler, maybe
> using some kind of decorator. IMO it would be good to
>
> 1. retain the ticket generation
> 2. notify admin by e-mail
> 3. redirect client to a custom error page
>
> I would like to do it site-wide - not using the decorators for all
> controller functions one-by-one.
>
> Please, I will appreciate your advices..
>
> Thanks a lot!
>
> David
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org
>
> iEYEARECAAYFAkqpBQ8ACgkQ3oCkkciamVEWpwCglAV9jvlB7qNYeqzBHe6kyj5a
> Z94AoKhys1cmmSRw9UYAnzIdIX3E57aU
> =/pZf
> -----END PGP SIGNATURE-----
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to