Commit e639dcf4 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

default is stable

--HG--
branch : stable
......@@ -20,3 +20,5 @@ ab3a1524c0230c80ca5e74e7ba0120978be8004c cubicweb-email-version-1.8.1
ed2720db906a426992fcd8435c0c161abff10f00 cubicweb-email-debian-version-1.8.1-1
c41f2e137bda9579b606d0b95d24153493044f48 cubicweb-email-version-1.8.2
590c68b7c579b202cf8e695a0a3809825906c272 cubicweb-email-debian-version-1.8.2-1
e71a87a21eabc99b3d765a9cca3fcf83c36f26c7 cubicweb-email-version-1.9.0
5045e769018ea4ba04df10ba3dd7c8c8b0d3c17a cubicweb-email-debian-version-1.9.0-1
......@@ -4,7 +4,7 @@
modname = 'email'
distname = "cubicweb-%s" % modname
numversion = (1, 8, 2)
numversion = (1, 9, 0)
version = '.'.join(str(num) for num in numversion)
license = 'LGPL'
......@@ -21,7 +21,9 @@ classifiers = [
# used packages
__depends__ = {'cubicweb': '>= 3.9.5',
'cubicweb-file': '>= 1.9.0'}
'cubicweb-file': '>= 1.9.0',
'logilab-common': '>= 0.58.3',
}
__recommends__ = {'cubicweb-comment': None}
......
......@@ -40,34 +40,52 @@ class MBOXImportCommand(Command):
'help': 'skip email signature.',
}),
)
autocommit = True
def run(self, args):
"""run the command with its specific arguments"""
appid = args.pop(0)
def import_mbox_files(self, importer, filenames):
"""process `filenames` with `importer` and create corresponding
Email / EmailThread / etc. objects in the database.
"""
for fpath in filenames:
if fpath == '-':
stream = StringIO(sys.stdin.read())
else:
stream = open(fpath)
importer.import_mbox_stream(stream)
if importer.error:
print 'failed to import the following messages:'
print '\n'.join(importer.error)
sys.exit(1)
def connect(self, appid):
"""create a connection to `appid`"""
cnx = config_connect(appid, self.config)
cnx.load_appobjects(cubes=None, subpath=('entities',))
importer = MBOXImporter(cnx, verbose=True,
interactive=self.config.interactive,
skipsign=self.config.skip_sign)
# set autocommit, add an option to control that if needed
importer.autocommit_mode()
return cnx
def create_importer(self, cnx):
"""factory to instantiate the mbox importer"""
return MBOXImporter(cnx, verbose=True,
interactive=self.config.interactive,
skipsign=self.config.skip_sign,
autocommit=self.autocommit)
def run(self, args):
"""run the command with its specific arguments"""
cnx = self.connect(args.pop(0))
importer = self.create_importer(cnx)
try:
for fpath in args:
if fpath == '-':
stream = StringIO(sys.stdin.read())
else:
stream = open(fpath)
importer.import_mbox_stream(stream)
if importer.error:
print 'failed to import the following messages:'
print '\n'.join(importer.error)
sys.exit(1)
self.import_mbox_files(importer, args)
except:
# without a correct connection handling we exhaust repository's
# connections pool.
# the repository should be more resilient against bad clients !
cnx.rollback()
cnx.close()
raise
if not self.autocommit:
cnx.commit()
cnx.close()
CWCTL.register(MBOXImportCommand)
cubicweb-email (1.9.0-1) precise; urgency=low
* new upstream release
-- David Douard <david.douard@logilab.fr> Wed, 14 Nov 2012 16:25:50 +0100
cubicweb-email (1.8.2-1) unstable; urgency=low
* new upstream release
......
......@@ -2,8 +2,8 @@ Source: cubicweb-email
Section: web
Priority: optional
Maintainer: Logilab Packaging Team <contact@logilab.fr>
Uploaders: Sylvain Thenault <sylvain.thenault@logilab.fr>, Laure Bourgois <laure.bourgois@logilab.fr>
Build-Depends: debhelper (>= 5.0.37.1), python (>=2.4), python-dev (>=2.4)
Uploaders: Sylvain Thenault <sylvain.thenault@logilab.fr>, David Douard <david.douard@logilab.fr>
Build-Depends: debhelper (>= 5.0.37.1), python (>=2.5), python-dev (>=2.5)
Standards-Version: 3.8.0
Homepage: http://www.cubicweb.org/project/cubicweb-email
......
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="language" content="fr">
<meta name="author" content="Logilab">
<meta name="organization" content="Logilab S.A.">
<meta name="generator" content="Logilab Powerful Stylesheets (v3)">
<title>Utilisation du script d'import d'emails dans une instance CubicWeb</title>
<meta name="keywords" content="logilab">
<link rel="stylesheet" href="http://www.logilab.fr/lglb-publi-content.css" type="text/css">
<link rel="stylesheet" href="http://www.logilab.fr/lglb-publi-structure.css" type="text/css">
</head>
<body>
<table class="header" cellspacing="0"><tbody><tr>
<td class="logo"><a href="http://www.logilab.fr/"><img src="http://www.logilab.fr/images/logilab.png" alt="Logilab" height="75"></a></td>
<td class="text"><div class="header-title">Utilisation du script d'import d'emails dans une instance CubicWeb</div></td>
</tr></tbody></table>
<div class="header-sep"></div>
<table class="main" cellspacing="0"><tbody><tr>
<td class="left-margin"></td>
<td class="body">
<div class="component-title-block"><div class="component-title">Utilisation du script d'import d'emails dans une instance CubicWeb</div></div>
<div class="sect1-title">
<a name="conditions"></a>1. Conditions</div>
<ul class="list">
<li class="listitem">
<div class="para">Le composant cubicweb-email doit être installés pour cette instance</div>
</li>
<li class="listitem">
<div class="para">Pyro doit être activé pour cette instance</div>
</li>
</ul>
<div class="sect1-title">
<a name="utilisation-en-ligne-de-commande"></a>2. Utilisation en ligne de commande</div>
<div class="para">La commande <span class="emphasis">mboximport</span> de <span class="emphasis">cubicweb-ctl</span> permet d'importer un fichier au format
Unix Mailbox. Il suffit de l'appeler en lui donnant en argument l'identifiant
de l'application et le fichier à importer. Par défaut votre nom d'utilisateur
sera utilisé pour se connecter à l'application, mais vous pouvez en spécifier un
autre avec l'option <span class="emphasis">-u</span>.</div>
<div class="sect1-title">
<a name="configuration-mutt"></a>3. Configuration mutt</div>
<div class="para">Dans le fichier <span class="emphasis">.muttrc</span>, ajouter par exemple la ligne :</div>
<div class="programlisting">
macro index "\ez" "&lt;pipe-message&gt;cubicweb-ctl mboximport -u toto -p toto monappli -&lt;enter&gt;"
</div>
<div class="para">et à partir de là vous pouvez faire "Alt-z" dans la vue d'index pour importer l'email
séléctionné dans l'instance. L'exemple ci-dessus suppose que :</div>
<ol class="list">
<li class="listitem">
<div class="para">l'identifiant pyro de l'application est "monappli"</div>
</li>
<li class="listitem">
<div class="para">Vous utilisez un compte toto / toto</div>
</li>
</ol>
<div class="para">Donner le mot de passe en ligne de commande est nécessaire car on ne sait pas le lire
correctement de manière interactive quand mutt lance la commande.</div>
</td>
</tr></tbody></table>
<div class="footer">Tous droits réservés à la société Logilab
S.A. - 104 bld Auguste Blanqui - F-75013 PARIS.</div>
</body>
</html>
......@@ -72,7 +72,8 @@ class Email(AnyEntity):
replyto = message.get('In-reply-to')
if replyto:
result.add(replyto)
result.update(message.get_all('References', ()))
for refs in message.get_all('References', ()):
result.update(refs.split())
return result
lines_rgx = re.compile('^Lines:\s*\d+\s*\n', re.I|re.U|re.M)
......
......@@ -36,7 +36,8 @@ def combinaison(list):
class MBOXImporter(object):
"""import content of a Unix mailbox into cubicweb as Email (and related) objects"""
def __init__(self, cnx, verbose=False, interactive=False, skipsign=False):
def __init__(self, cnx, verbose=False, interactive=False,
skipsign=False, autocommit=False):
self.cnx = cnx
self.schema = cnx.get_schema()
self.req = cnx.request()
......@@ -47,7 +48,7 @@ class MBOXImporter(object):
self.created = {}
self.skipped = []
self.error = []
self.autocommit = False
self.autocommit = autocommit
def autocommit_mode(self):
self.autocommit = True
......@@ -63,9 +64,11 @@ class MBOXImporter(object):
self.skipped.append(messageid)
def import_mbox_stream(self, stream):
from mailbox import UnixMailbox
from mailbox import UnixMailbox as Mailbox
from rfc822 import parsedate
from logilab.common.umessage import message_from_file
for message in UnixMailbox(stream, message_from_file):
for message in sorted(Mailbox(stream, message_from_file),
key=lambda x:parsedate(x['Date'])):
try:
self.import_message(message)
if self.autocommit:
......
......@@ -25,7 +25,7 @@ except ImportError:
sys.modules.pop('__pkginfo__', None)
# import required features
from __pkginfo__ import modname, version, license, description, \
web, author, author_email
web, author, author_email, classifiers
# import optional features
import __pkginfo__
distname = getattr(__pkginfo__, 'distname', modname)
......@@ -157,6 +157,7 @@ def install(**kwargs):
data_files = data_files,
ext_modules = ext_modules,
cmdclass = {'install_lib': MyInstallLib},
classifiers = classifiers,
**kwargs
)
......
......@@ -11,6 +11,7 @@ from logilab.mtconverter import xml_escape
from cubicweb.selectors import is_instance
from cubicweb.uilib import soup2xhtml
from cubicweb.view import EntityView
from cubicweb.web import uicfg, formwidgets
from cubicweb.web.views import baseviews, primary
......@@ -133,12 +134,11 @@ class EmailPartOutOfContextView(baseviews.OutOfContextView):
entity.reverse_parts[0].view('outofcontext', w=self.w)
class EmailThreadPrimaryView(primary.PrimaryView):
class EmailThreadView(EntityView):
__regid__ = 'emailthread'
__select__ = is_instance('EmailThread')
def cell_call(self, row, col):
entity = self.cw_rset.complete_entity(row, col)
self.w(u'<h1>%s</h1>' % xml_escape(entity.title))
def entity_call(self, entity):
# get top level emails in this thread (ie message which are not a reply
# of a message in this thread)
#
......@@ -161,3 +161,11 @@ class EmailThreadPrimaryView(primary.PrimaryView):
self.w(u'</ul>')
class EmailThreadPrimaryView(primary.PrimaryView):
__select__ = is_instance('EmailThread')
def cell_call(self, row, col):
entity = self.cw_rset.complete_entity(row, col)
self.w(u'<h1>%s</h1>' % xml_escape(entity.title))
entity.view('emailthread', w=self.w)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment