From 9911322d46c49d997401fa337edb19edbd967702 Mon Sep 17 00:00:00 2001
From: Nicolas Dumazet <nicolas.dumazet@nexedi.com>
Date: Tue, 9 Mar 2010 07:00:36 +0000
Subject: [PATCH] Add access to rfc822 to allow email parsing

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33513 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/Utils.py    | 10 ++++++++++
 product/ERP5Type/__init__.py |  3 ++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/product/ERP5Type/Utils.py b/product/ERP5Type/Utils.py
index 10bb0a82b1..7b8fa96d8a 100644
--- a/product/ERP5Type/Utils.py
+++ b/product/ERP5Type/Utils.py
@@ -341,6 +341,16 @@ def getTranslationStringWithContext(self, msg_id, context, context_id):
      result = localizer.erp5_ui.gettext(msg_id)
    return result.encode('utf8')
 
+from rfc822 import AddressList
+
+def Email_parseAddressHeader(text):
+  """
+  Given a text taken from a From/To/CC/... email header,
+  return a list of tuples (name, address) extracted from
+  this header
+  """
+  return AddressList(text).addresslist
+
 #####################################################
 # Globals initialization
 #####################################################
diff --git a/product/ERP5Type/__init__.py b/product/ERP5Type/__init__.py
index 0c0ab7722d..cdee6f7006 100644
--- a/product/ERP5Type/__init__.py
+++ b/product/ERP5Type/__init__.py
@@ -135,7 +135,8 @@ allow_module('Products.ERP5Type.Cache')
 ModuleSecurityInfo('Products.ERP5Type.Utils').declarePublic(
     'sortValueList', 'convertToUpperCase', 'UpperCase',
     'convertToMixedCase', 'cartesianProduct', 'sleep', 'getCommonTimeZoneList',
-    'int2letter', 'getMessageIdWithContext', 'getTranslationStringWithContext')
+    'int2letter', 'getMessageIdWithContext', 'getTranslationStringWithContext',
+    'Email_parseAddressHeader')
 
 allow_module('Products.ERP5Type.Message')
 ModuleSecurityInfo('Products.ERP5Type.Message').declarePublic('translateString')
-- 
2.30.9