[Erp5-dev] [Erp5-report] r19169 - in /erp5/trunk/products/CMFActivity: ./ Activity/
Yoshinori Okuji
yo at nexedi.com
Fri Feb 8 15:42:00 CET 2008
I would like to understand why this change has been made. The original code
avoided explicitly making circular references.
(FYI, read the description of exc_info at
http://docs.python.org/lib/module-sys.html .)
YO
On Friday 08 February 2008 13:28, nobody at svn.erp5.org wrote:
> Author: vincent
> Date: Fri Feb 8 13:28:30 2008
> New Revision: 19169
>
> URL: http://svn.erp5.org?rev=19169&view=rev
> Log:
> Store exception information in native format inside message. Factorises
> sys.exc_info calls and exception rendering code.
>
> Modified:
> erp5/trunk/products/CMFActivity/Activity/SQLDict.py
> erp5/trunk/products/CMFActivity/Activity/SQLQueue.py
> erp5/trunk/products/CMFActivity/ActivityTool.py
>
> Modified: erp5/trunk/products/CMFActivity/Activity/SQLDict.py
> URL:
> http://svn.erp5.org/erp5/trunk/products/CMFActivity/Activity/SQLDict.py?rev
>=19169&r1=19168&r2=19169&view=diff
> ===========================================================================
>=== --- erp5/trunk/products/CMFActivity/Activity/SQLDict.py (original) +++
> erp5/trunk/products/CMFActivity/Activity/SQLDict.py Fri Feb 8 13:28:30
> 2008 @@ -331,8 +331,9 @@
> if m.active_process:
> message_with_active_process_list.append(m)
> else:
> - if type(m.exc_type) is ClassType and \
> - issubclass(m.exc_type, ConflictError):
> + exc_type = m.exc_info[0]
> + if type(exc_type) is ClassType and \
> + issubclass(exc_type, ConflictError):
> delay_uid_list.append(uid)
> elif priority > MAX_PRIORITY:
> notify_user_list.append(m)
>
> Modified: erp5/trunk/products/CMFActivity/Activity/SQLQueue.py
> URL:
> http://svn.erp5.org/erp5/trunk/products/CMFActivity/Activity/SQLQueue.py?re
>v=19169&r1=19168&r2=19169&view=diff
> ===========================================================================
>=== --- erp5/trunk/products/CMFActivity/Activity/SQLQueue.py (original) +++
> erp5/trunk/products/CMFActivity/Activity/SQLQueue.py Fri Feb 8 13:28:30
> 2008 @@ -198,8 +198,9 @@
> if m.active_process:
> message_with_active_process_list.append(m)
> else:
> - if type(m.exc_type) is ClassType and \
> - issubclass(m.exc_type, ConflictError):
> + exc_type = m.exc_info[0]
> + if type(exc_type) is ClassType and \
> + issubclass(exc_type, ConflictError):
> delay_uid_list.append(uid)
> elif priority > MAX_PRIORITY:
> notify_user_list.append(m)
>
> Modified: erp5/trunk/products/CMFActivity/ActivityTool.py
> URL:
> http://svn.erp5.org/erp5/trunk/products/CMFActivity/ActivityTool.py?rev=191
>69&r1=19168&r2=19169&view=diff
> ===========================================================================
>=== --- erp5/trunk/products/CMFActivity/ActivityTool.py (original)
> +++ erp5/trunk/products/CMFActivity/ActivityTool.py Fri Feb 8 13:28:30
> 2008 @@ -117,9 +117,7 @@
> self.args = args
> self.kw = kw
> self.is_executed = 0
> - self.exc_type = None
> - self.exc_value = None
> - self.traceback = None
> + self.exc_info = (None, None, None)
> self.processing = None
> self.user_name = str(_getAuthenticatedUser(self))
> # Store REQUEST Info ?
> @@ -201,16 +199,13 @@
> self.is_executed = 1
> except:
> self.is_executed = 0
> - self.exc_type = sys.exc_info()[0]
> - self.exc_value = str(sys.exc_info()[1])
> - self.traceback = ''.join(ExceptionFormatter.format_exception(
> - *sys.exc_info()))
> + self.exc_info = sys.exc_info()
> LOG('ActivityTool', WARNING,
> 'Could not call method %s on object %s' % (
> - self.method_id, self.object_path), error=sys.exc_info())
> + self.method_id, self.object_path), error=self.exc_info)
> # push the error in ZODB error_log
> if getattr(activity_tool, 'error_log', None) is not None:
> - activity_tool.error_log.raising(sys.exc_info())
> + activity_tool.error_log.raising(self.exc_info)
>
> def validate(self, activity, activity_tool, check_order_validation=1):
> return activity.validate(activity_tool, self,
> @@ -238,16 +233,17 @@
>
> Document: %s
> Method: %s
> -Exception: %s %s
>
> %s
> """ % (activity_tool.email_from_address, user_email, message,
> message, '/'.join(self.object_path), self.method_id,
> - self.exc_type, self.exc_value, self.traceback)
> + ''.join(ExceptionFormatter.format_exception(*self.exc_info)))
> try:
> activity_tool.MailHost.send( mail_text )
> - except (socket.error, MailHostError), message:
> - LOG('ActivityTool.notifyUser', WARNING, 'Mail containing failure
> information failed to be sent: %s. Exception was: %s %s\n%s' % (message,
> self.exc_type, self.exc_value, self.traceback)) + except (socket.error,
> MailHostError):
> + LOG('ActivityTool.notifyUser', WARNING, 'Mail containing failure
> information failed to be sent.', error=sys.exc_info()) + if
> self.exc_info[0] is not None:
> + LOG('ActivityTool.notifyUser', WARNING, 'Original exception',
> error=self.exc_info)
>
> def reactivate(self, activity_tool):
> # Reactivate the original object.
> @@ -843,10 +839,10 @@
> new_message_list.append(m)
> except:
> m.is_executed = 0
> - m.exc_type = sys.exc_info()[0]
> + m.exc_info = sys.exc_info()
> LOG('WARNING ActivityTool', 0,
> 'Could not call method %s on object %s' %
> - (m.method_id, m.object_path), error=sys.exc_info())
> + (m.method_id, m.object_path), error=m.exc_info)
>
> try:
> if len(expanded_object_list) > 0:
> @@ -861,10 +857,10 @@
> # In this case, the group method completely failed.
> for m in new_message_list:
> m.is_executed = 0
> - m.exc_type = sys.exc_info()[0]
> + m.exc_info = sys.exc_info()
> LOG('WARNING ActivityTool', 0,
> 'Could not call method %s on objects %s' %
> - (method_id, expanded_object_list), error=sys.exc_info())
> + (method_id, expanded_object_list), error=m.exc_info)
> else:
> # Obtain all indices of failed messages. Note that this can be a
> partial failure. failed_message_dict = {}
> @@ -888,10 +884,10 @@
> m.is_executed = 1
> except:
> m.is_executed = 0
> - m.exc_type = sys.exc_info()[0]
> + m.exc_info = sys.exc_info()
> LOG('ActivityTool', WARNING,
> 'Could not call method %s on object %s' % (
> - m.method_id, m.object_path), error=sys.exc_info())
> + m.method_id, m.object_path), error=m.exc_info)
>
> def newMessage(self, activity, path, active_process,
> activity_kw, method_id, *args, **kw):
>
> _______________________________________________
> Erp5-report mailing list
> Erp5-report at erp5.org
> http://mail.nexedi.com/mailman/listinfo/erp5-report
--
Yoshinori Okuji, Nexedi CTO
Nexedi: Consulting and Development of Free / Open Source Software
http://www.nexedi.com
ERP5: Full Featured High End Open Source ERP
http://www.erp5.com
ERP5 Wiki: Developer Zone for ERP5 Community
http://www.erp5.org
More information about the Erp5-dev
mailing list