this:  decoupling from web2py is critical if it is to be useful.
Further, it is something that should be thought of as being decoupled from,
on a different server.


On Wed, Nov 12, 2008 at 11:45 AM, mdipierro <[EMAIL PROTECTED]> wrote:

>
> Mark,
>
> please talk to Tim. We just included (1.48) his patch for
> "routes_onerror". I believe what you are proposing has a lot of
> superposition with what he proposed and can handled already by the
> current version of web2py.
>
> Mind that sending emails on error has one problem... what if the
> function that sends the email causes an error? Do you go in one loop
> and send hundreds of emails? I have seen this last week when I got 850
> email in 10 minutes (it was not a web2py app).
>
> I think there should be a daemon that monitors tickets (from database
> or filesystem) and is in charge of sending emails. This must be
> decoupled from web2py actions.
>
> Massimo
>
> On Nov 12, 11:39 am, Mark Larsen <[EMAIL PROTECTED]> wrote:
> > web2py users,
> >
> > web2pys default mechanism for exception handling works great in
> > development but when shifted into production I'd rather have the
> > application email on exception and display a sorry message to the
> > user.  I'm proposing a new file in the root of web2py
> > "customexception.py", If this file does not exist (or if it returns
> > None or False) web2py's default exception mechanism is used.  If it
> > does exist and returns a str then the code within is executed.
> >
> > I've coded this up quickly in the last hour or so.  I pass the
> > following environment to be executed in "customexception.py"
> >
> > environment={'layer':str(self.layer),
> >            'code':str(self.code),
> >            'output':str(self.output),
> >            'traceback':str(self.traceback),
> >            'application': request.application,
> >            'rv': None}
> >
> > where
> >
> > layer => path to executing code
> > code => block of code that exec was called on
> > output => string output, not sure how to use this, maybe rv is
> > redundant?
> > traceback => exception traceback
> > application => application being executed
> > rv => return value for this handler, set to None or False to do
> > nothing
> >       set to string for text to display to user
> >
> > within your file you set rv to a string to display to the user, set it
> > to None or False to have web2pys default mechanism used.
> >
> > An example of a "customexception.py" file would be:
> >
> > [code]
> > '''
> > Author: Mark Larsen
> > Date: 11/12/08
> > Method to handle custom exceptions
> >
> > If this file exists and rv evaluates true web2py will use this
> > to handle exceptions instead of built-in method
> >
> > I mainly want this to send me emails in a production environment.
> >
> > variables passed in are
> > layer => path to executing code
> > code => block of code that exec was called on
> > output => string output
> > traceback => exception traceback
> > application => application being executed
> > rv => return value for this handler, set to None or False to do
> > nothing
> >       set to string for text to display to user
> > '''
> >
> > import smtplib
> >
> > smtpserver = 'localhost' ## assumes smtp server on localhost, i use
> > sendmail
> > toaddrs = ['[EMAIL PROTECTED]']
> > fromaddr = '[EMAIL PROTECTED]'
> > subject = 'Unhandled Exception in %s application' % application
> >
> > msg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (fromaddr, ",
> > ".join(toaddrs), subject))
> >
> > msg+="An error has occured in %s \n\n" % layer
> > msg+=traceback
> > msg+="\n\nIn code block: \n\n"
> > msg+=code
> >
> > server = smtplib.SMTP(smtpserver)
> > server.sendmail(fromaddr,toaddrs,msg)
> > server.quit()
> >
> > rv = "Unfortunately a serious error has occurred."
> >
> > [/code]
> >
> > Anyone interested in something like this?
> >
> > Thanks,
> >
> > Mark
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to