378 # assignement to ``content`` prevent standard |
378 # assignement to ``content`` prevent standard |
379 # AuthenticationError code to overwrite it. |
379 # AuthenticationError code to overwrite it. |
380 content = self.loggedout_content(req) |
380 content = self.loggedout_content(req) |
381 # let the explicitly reset http credential |
381 # let the explicitly reset http credential |
382 raise AuthenticationError() |
382 raise AuthenticationError() |
383 except Redirect, ex: |
383 except Redirect as ex: |
384 # authentication needs redirection (eg openid) |
384 # authentication needs redirection (eg openid) |
385 content = self.redirect_handler(req, ex) |
385 content = self.redirect_handler(req, ex) |
386 # Wrong, absent or Reseted credential |
386 # Wrong, absent or Reseted credential |
387 except AuthenticationError: |
387 except AuthenticationError: |
388 # If there is an https url configured and |
388 # If there is an https url configured and |
439 appli=self) |
439 appli=self) |
440 except NoSelectableObject: |
440 except NoSelectableObject: |
441 raise Unauthorized(req._('not authorized')) |
441 raise Unauthorized(req._('not authorized')) |
442 req.update_search_state() |
442 req.update_search_state() |
443 result = controller.publish(rset=rset) |
443 result = controller.publish(rset=rset) |
444 except StatusResponse, ex: |
444 except StatusResponse as ex: |
445 warn('StatusResponse is deprecated use req.status_out', |
445 warn('StatusResponse is deprecated use req.status_out', |
446 DeprecationWarning) |
446 DeprecationWarning) |
447 result = ex.content |
447 result = ex.content |
448 req.status_out = ex.status |
448 req.status_out = ex.status |
449 except Redirect, ex: |
449 except Redirect as ex: |
450 # Redirect may be raised by edit controller when everything went |
450 # Redirect may be raised by edit controller when everything went |
451 # fine, so attempt to commit |
451 # fine, so attempt to commit |
452 result = self.redirect_handler(req, ex) |
452 result = self.redirect_handler(req, ex) |
453 if req.cnx: |
453 if req.cnx: |
454 txuuid = req.cnx.commit() |
454 txuuid = req.cnx.commit() |
455 commited = True |
455 commited = True |
456 if txuuid is not None: |
456 if txuuid is not None: |
457 req.data['last_undoable_transaction'] = txuuid |
457 req.data['last_undoable_transaction'] = txuuid |
458 ### error case |
458 ### error case |
459 except NotFound, ex: |
459 except NotFound as ex: |
460 result = self.notfound_content(req) |
460 result = self.notfound_content(req) |
461 req.status_out = ex.status |
461 req.status_out = ex.status |
462 except ValidationError, ex: |
462 except ValidationError as ex: |
463 result = self.validation_error_handler(req, ex) |
463 result = self.validation_error_handler(req, ex) |
464 except RemoteCallFailed, ex: |
464 except RemoteCallFailed as ex: |
465 result = self.ajax_error_handler(req, ex) |
465 result = self.ajax_error_handler(req, ex) |
466 except Unauthorized, ex: |
466 except Unauthorized as ex: |
467 req.data['errmsg'] = req._('You\'re not authorized to access this page. ' |
467 req.data['errmsg'] = req._('You\'re not authorized to access this page. ' |
468 'If you think you should, please contact the site administrator.') |
468 'If you think you should, please contact the site administrator.') |
469 req.status_out = httplib.UNAUTHORIZED |
469 req.status_out = httplib.UNAUTHORIZED |
470 result = self.error_handler(req, ex, tb=False) |
470 result = self.error_handler(req, ex, tb=False) |
471 except Forbidden, ex: |
471 except Forbidden as ex: |
472 req.data['errmsg'] = req._('This action is forbidden. ' |
472 req.data['errmsg'] = req._('This action is forbidden. ' |
473 'If you think it should be allowed, please contact the site administrator.') |
473 'If you think it should be allowed, please contact the site administrator.') |
474 req.status_out = httplib.FORBIDDEN |
474 req.status_out = httplib.FORBIDDEN |
475 result = self.error_handler(req, ex, tb=False) |
475 result = self.error_handler(req, ex, tb=False) |
476 except (BadRQLQuery, RequestError), ex: |
476 except (BadRQLQuery, RequestError) as ex: |
477 result = self.error_handler(req, ex, tb=False) |
477 result = self.error_handler(req, ex, tb=False) |
478 ### pass through exception |
478 ### pass through exception |
479 except DirectResponse: |
479 except DirectResponse: |
480 if req.cnx: |
480 if req.cnx: |
481 req.cnx.commit() |
481 req.cnx.commit() |
482 raise |
482 raise |
483 except (AuthenticationError, LogOut): |
483 except (AuthenticationError, LogOut): |
484 # the rollback is handled in the finally |
484 # the rollback is handled in the finally |
485 raise |
485 raise |
486 ### Last defense line |
486 ### Last defense line |
487 except BaseException, ex: |
487 except BaseException as ex: |
488 result = self.error_handler(req, ex, tb=True) |
488 result = self.error_handler(req, ex, tb=True) |
489 finally: |
489 finally: |
490 if req.cnx and not commited: |
490 if req.cnx and not commited: |
491 try: |
491 try: |
492 req.cnx.rollback() |
492 req.cnx.rollback() |