web/application.py
changeset 5868 c4380d8cfc25
parent 5736 375819ec7d43
parent 5865 af414723598d
child 6012 d56fd78006cd
child 6109 47d9c0e0f7b7
equal deleted inserted replaced
5863:4495b9bc49df 5868:c4380d8cfc25
   371         # don't log form values they may contains sensitive information
   371         # don't log form values they may contains sensitive information
   372         self.info('publish "%s" (form params: %s)', path, req.form.keys())
   372         self.info('publish "%s" (form params: %s)', path, req.form.keys())
   373         # remove user callbacks on a new request (except for json controllers
   373         # remove user callbacks on a new request (except for json controllers
   374         # to avoid callbacks being unregistered before they could be called)
   374         # to avoid callbacks being unregistered before they could be called)
   375         tstart = clock()
   375         tstart = clock()
       
   376         commited = False
   376         try:
   377         try:
   377             try:
   378             try:
   378                 ctrlid, rset = self.url_resolver.process(req, path)
   379                 ctrlid, rset = self.url_resolver.process(req, path)
   379                 try:
   380                 try:
   380                     controller = self.vreg['controllers'].select(ctrlid, req,
   381                     controller = self.vreg['controllers'].select(ctrlid, req,
   388                 if req.cnx:
   389                 if req.cnx:
   389                     # no req.cnx if anonymous aren't allowed and we are
   390                     # no req.cnx if anonymous aren't allowed and we are
   390                     # displaying some anonymous enabled view such as the cookie
   391                     # displaying some anonymous enabled view such as the cookie
   391                     # authentication form
   392                     # authentication form
   392                     req.cnx.commit()
   393                     req.cnx.commit()
       
   394                     commited = True
   393             except (StatusResponse, DirectResponse):
   395             except (StatusResponse, DirectResponse):
   394                 if req.cnx:
   396                 if req.cnx:
   395                     req.cnx.commit()
   397                     req.cnx.commit()
   396                 raise
   398                 raise
   397             except (AuthenticationError, LogOut):
   399             except (AuthenticationError, LogOut):
   431                 self.error_handler(req, ex, tb=True)
   433                 self.error_handler(req, ex, tb=True)
   432             except:
   434             except:
   433                 self.critical('Catch all triggered!!!')
   435                 self.critical('Catch all triggered!!!')
   434                 self.exception('this is what happened')
   436                 self.exception('this is what happened')
   435         finally:
   437         finally:
   436             if req.cnx:
   438             if req.cnx and not commited:
   437                 try:
   439                 try:
   438                     req.cnx.rollback()
   440                     req.cnx.rollback()
   439                 except:
   441                 except:
   440                     pass # ignore rollback error at this point
   442                     pass # ignore rollback error at this point
   441         self.info('query %s executed in %s sec', req.relative_path(), clock() - tstart)
   443         self.info('query %s executed in %s sec', req.relative_path(), clock() - tstart)