Commit 3a6bdb36 authored by Nicolas Chauvat's avatar Nicolas Chauvat
Browse files

first public release

parents
include *.py
include views/*.py
recursive-include data external_resources *.gif
recursive-include i18n *.pot *.po
recursive-include migration *.py
recursive-include views *.py
recursive-include doc *.txt *.html
"""package __init__"""
from cubicweb import ETYPE_NAME_MAP
ETYPE_NAME_MAP['Emailpart'] = 'EmailPart'
ETYPE_NAME_MAP['Emailthread'] = 'EmailThread'
try:
from cubicweb.devtools import VIEW_VALIDATORS
VIEW_VALIDATORS['headers'] = None
except ImportError:
pass
# pylint: disable-msg=W0622
"""cubicweb-email packaging information"""
distname = "cubicweb-email"
numversion = (1, 3, 0)
version = '.'.join(str(num) for num in numversion)
license = 'LGPL'
copyright = '''Copyright (c) 2003-2008 LOGILAB S.A. (Paris, FRANCE).
http://www.logilab.fr/ -- mailto:contact@logilab.fr'''
author = "Logilab"
author_email = "contact@logilab.fr"
web = ''
short_desc = "Email support for the CubicWeb framework"
long_desc = """CubicWeb is a entities / relations bases knowledge management system
developped at Logilab.
.
This package provides schema and views to store emails in cubicweb applications.
.
"""
from os import listdir
from os.path import join
CUBES_DIR = join('share', 'cubicweb', 'cubes')
try:
data_files = [
[join(CUBES_DIR, 'email'),
[fname for fname in listdir('.')
if fname.endswith('.py') and fname != 'setup.py']],
[join(CUBES_DIR, 'email', 'views'),
[join('views', fname) for fname in listdir('views')
if not fname.endswith('.pyc')]],
#[join(CUBES_DIR, 'email', 'data'),
# [join('data', fname) for fname in listdir('data')]],
[join(CUBES_DIR, 'email', 'i18n'),
[join('i18n', fname) for fname in listdir('i18n')]],
[join(CUBES_DIR, 'email', 'migration'),
[join('migration', fname) for fname in listdir('migration')]],
]
except OSError:
# we are in an installed directory
pass
cube_eid = 20324
# used packages
__use__ = ('file',)
__recommend__ = ('comment',)
MAIL_ICON = DATADIR/mail.gif
cubicweb-email (1.3.0-1) unstable; urgency=low
* new upstream release
-- Adrien Di Mascio <Adrien.DiMascio@logilab.fr> Wed, 24 Sep 2008 18:18:50 +0200
cubicweb-email (1.2.4-1) unstable; urgency=low
* new upstream release
-- Sylvain Thénault <Sylvain.Thenault@logilab.fr> Fri, 06 Jun 2008 12:41:02 +0200
cubicweb-email (1.2.3-1) unstable; urgency=low
* new upstream release
-- Nicolas Chauvat <Nicolas.Chauvat@logilab.fr> Mon, 12 May 2008 22:11:08 +0200
cubicweb-email (1.2.2-1) unstable; urgency=low
* new upstream release
-- Sylvain Thénault <Sylvain.Thenault@logilab.fr> Wed, 26 Mar 2008 11:34:52 +0100
cubicweb-email (1.2.1-1) unstable; urgency=low
* new upstream release
* update standards version and fix section in control
-- Sylvain Thénault <Sylvain.Thenault@logilab.fr> Wed, 27 Feb 2008 10:55:30 +0100
cubicweb-email (1.2.0-1) unstable; urgency=low
* new upstream release
-- Sylvain Thénault <sylvain.thenault@logilab.fr> Fri, 15 Feb 2008 12:04:05 +0100
cubicweb-email (1.1.2-1) unstable; urgency=low
* new upstream release
-- Adrien.DiMascio <Adrien.DiMascio@logilab.fr> Wed, 06 Feb 2008 08:33:04 +0100
cubicweb-email (1.1.1-1) unstable; urgency=low
* new upstream release
-- Sylvain Thénault <Sylvain.Thenault@logilab.fr> Tue, 29 Jan 2008 13:09:38 +0100
cubicweb-email (1.1.0-1) unstable; urgency=low
* add debian/compat and debian/pycompat files, remove DH_COMPAT from rules
* fixed uploaders/maintainer in debian/control
* new upstream release
-- Sylvain Thénault <Sylvain.Thenault@logilab.fr> Fri, 25 Jan 2008 10:11:51 +0100
cubicweb-email (1.0.3-1) unstable; urgency=low
* new upstream release
-- Sylvain Thénault <Sylvain.Thenault@logilab.fr> Mon, 26 Nov 2007 16:32:50 +0100
cubicweb-email (1.0.2-1) unstable; urgency=low
* more packaging fixes :/
-- Sylvain Thénault <sylvain.thenault@logilab.fr> Tue, 30 Oct 2007 18:51:43 +0100
cubicweb-email (1.0.1-1) unstable; urgency=low
* packaging fixes
-- Sylvain Thénault <sylvain.thenault@logilab.fr> Tue, 30 Oct 2007 17:49:25 +0100
cubicweb-email (1.0.0-1) unstable; urgency=low
* initial upstream release
-- Sylvain Thénault <Sylvain.Thenault@logilab.fr> Tue, 18 Sep 2007 16:31:38 +0200
Source: cubicweb-email
Section: web
Priority: optional
Maintainer: Logilab Packaging Team <contact@logilab.fr>
Uploaders: Sylvain Thenault <sylvain.thenault@logilab.fr>
Build-Depends: debhelper (>= 5.0.37.1), python (>=2.4), python-dev (>=2.4)
Standards-Version: 3.7.3
Package: cubicweb-email
Architecture: all
Depends: cubicweb-email-server (>= ${source:Version}), cubicweb-email-client (>= ${source:Version})
Description: Email support for the CubicWeb framework
CubicWeb is a entities / relations based knowledge management system
developed at Logilab.
.
This package provides schema and views to store emails in cubicweb
applications.
.
This package will install all the components you need to use the
email component on a single machine. You can also deploy cubicweb by
running the different process on different computers, in which case
you need to install the corresponding packages on the different
hosts.
Package: cubicweb-email-server
Architecture: all
Depends: cubicweb-server (>= 2.50.0), cubicweb-file-server, cubicweb-email-comp (>= ${source:Version})
Description: Email support for the CubicWeb framework (repository)
CubicWeb is a entities / relations bases knowledge management system
developed at Logilab.
.
This package provides schema and views to store emails in cubicweb
applications.
.
This package is a virtual package providing necessary package for the
repository server part of the email component for CubicWeb.
Package: cubicweb-email-client
Architecture: all
Depends: cubicweb-twisted (>= 2.50.0) | cubicweb-web-frontend, cubicweb-file-client, cubicweb-email-comp (>= ${source:Version})
Description: Email support for the CubicWeb framework (web)
CubicWeb is a entities / relations bases knowledge management system
developed at Logilab.
.
This package provides schema and views to store emails in cubicweb
applications.
.
This package is a virtual package providing necessary package for the
web client part of the email component for CubicWeb.
Package: cubicweb-email-comp
Architecture: all
Depends: python2.4
Description: Email support for the CubicWeb framework
CubicWeb is a entities / relations based knowledge management system
developed at Logilab.
.
This package provides schema and views to store emails in cubicweb
applications.
.
This package will install all the components you need to use the
email component on a single machine. You can also deploy cubicweb by
running the different process on different computers, in which case
you need to install the corresponding packages on the different
hosts.
This package was debianized by Logilab <contact@logilab.fr>.
Upstream Author:
Logilab <contact@logilab.fr>
Copyright:
Copyright (c) 2003-2007 LOGILAB S.A. (Paris, FRANCE).
http://www.logilab.fr/ -- mailto:contact@logilab.fr
Logilab Closed source License. This code is *NOT* open-source. Usage of this
code is subject to a licence agreement. If you want to use it, you should
contact logilab's sales service at commercial@logilab.fr .
usr/share/cubicweb/cubes/email/
#!/bin/sh -e
delete_pyo_pyc () {
find /usr/share/cubicweb/cubes/email -name "*.pyc" | xargs rm -f
find /usr/share/cubicweb/cubes/email -name "*.pyo" | xargs rm -f
}
case "$1" in
failed-upgrade|abort-install|abort-upgrade|disappear)
;;
upgrade)
delete_pyo_pyc
;;
remove)
delete_pyo_pyc
;;
purge)
;;
*)
echo "postrm called with unknown argument \`$1'" >&2
exit 1
esac
#DEBHELPER#
#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
build: build-stamp
build-stamp:
dh_testdir
python setup.py -q build
touch build-stamp
clean:
dh_testdir
dh_testroot
rm -f build-stamp configure-stamp
rm -rf build
find . -name "*.pyc" | xargs rm -f
rm -f changelog.gz
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs -i
python setup.py -q install --no-compile --prefix=debian/cubicweb-email-comp/usr/
cp doc/*.html doc/*.txt debian/cubicweb-email-comp/usr/share/doc/cubicweb-email-comp/
# Build architecture-independent files here.
binary-indep: build install
dh_testdir
dh_testroot
dh_install -i
# dh_pycentral -i
# dh_python -i
# gzip -9 -c ChangeLog > changelog.gz
dh_installchangelogs -i
dh_installexamples -i
dh_installdocs -i
dh_installman -i
dh_link -i
dh_compress -i -X.py -X.ini -X.xml -Xtest
dh_fixperms -i
dh_installdeb -i
dh_gencontrol -i
dh_md5sums -i
dh_builddeb -i
# Build architecture-dependent files here.
binary-arch:
binary: binary-indep
.PHONY: build clean binary-arch binary-indep binary
.. -*- coding: utf-8 -*-
Utilisation du script d'import d'emails dans une instance CubicWeb
---------------------------------------------------------------
Conditions
~~~~~~~~~~
* Le composant cubicweb-email doit être installés pour cette instance
* Pyro doit être activé pour cette instance
Utilisation en ligne de commande
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
La commande `mboximport` de `cubicweb-ctl` 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 `-u`.
Configuration mutt
~~~~~~~~~~~~~~~~~~
Dans le fichier *.muttrc*, ajouter par exemple la ligne : ::
macro index "\ez" "<pipe-message>cubicweb-ctl mboximport -u ocy -p ocy drh -<enter>"
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 :
1. l'identifiant pyro de l'application est "drh"
2. Vous utilisez un compte ocy / ocy
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.
MKHTML=mkdoc
MKHTMLOPTS=--doctype article --target html --stylesheet single-file
SRC=.
TXTFILES:= $(wildcard *.txt)
TARGET := $(TXTFILES:.txt=.html)
all: ${TARGET}
%.html: %.txt
${MKHTML} ${MKHTMLOPTS} $<
clean:
rm -f *.html
"""cubicweb-ctl plugin providing the mboximport command
:organization: Logilab
:copyright: 2007-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""
__docformat__ = "restructuredtext en"
import sys
from cStringIO import StringIO
from cubicweb.toolsutils import (CONNECT_OPTIONS, Command,
register_commands, config_connect, pop_arg)
from cubes.email.mboximport import MBOXImporter
class MBOXImportCommand(Command):
"""Import files using the Unix mail box format into an cubicweb application.
The application must use the email package.
<pyro id>
pyro identifier of the application where emails have to be imported.
<mbox file>
path to a file using the Unix MBOX format. If "-" is given, stdin is read.
"""
name = 'mboximport'
arguments = '<pyro id> <mbox file>'
options = CONNECT_OPTIONS + (
("interactive",
{'short': 'i', 'action' : 'store_true',
'default': False,
'help': 'ask confirmation to continue after an error.',
}),
)
def run(self, args):
"""run the command with its specific arguments"""
appid = pop_arg(args, expected_size_after=None)
cnx = config_connect(appid, self.config)
cnx.load_vobjects(packages=None, subpath=('entities',))
importer = MBOXImporter(cnx.cursor(), cnx.get_schema(),
verbose=True, interactive=self.config.interactive)
# set autocommit, add an option to control that if needed
importer.autocommit_mode(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)
except:
# without a correct connection handling we exhaust repository's
# connections pool.
# the repository should be more resilient against bad clients !
cnx.close()
raise
cnx.close()
register_commands((MBOXImportCommand,))
"""some utilities to process email information
:organization: Logilab
:copyright: 2007-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""
__docformat__ = "restructuredtext en"
def parse_body(body, quote='>'):
"""return a `ParsedMessage` instance where actual content is separated from
cited content
"""
res = []
level = 0
current = []
seenlevels = set()
for line in body.splitlines(True):
newlevel = 0
while line.startswith(quote):
newlevel += 1
line = line[1:].lstrip()
if line.strip() == '--':
break # ignore following signature
if newlevel != level:
# detect lines such as
# On Wed, Jan 23, 2008 at 06:48:22PM +0100, machin wrote:
# preceding citation
if not newlevel in seenlevels and res and res[-1][1] and \
res[-1][1][-1].rstrip().endswith(':'):
current.insert(0, res[-1][1].pop())
seenlevels.add(newlevel)
res.append( (level, current) )
current = []
level = newlevel
current.append(line)
res.append( (level, current) )
pmsg = ParsedMessage()
for level, lines in res:
para = ''.join(lines).strip()
if not para:
continue
if level > 0 :
pmsg.cites.append(para)
else:
pmsg.content.append(para)
return pmsg
class ParsedMessage(object):
def __init__(self):
self.content = []
self.cites = []
@property
def actual_content(self):
return '\n'.join(self.content)
@property
def cited_content(self):
return '\n'.join(self.cites)
# import sys
# from mailbox import UnixMailbox
# from maboa.umessage import message_from_file
# from cubicweb.web.uilib import remove_html_tags
# def ignore_cite(para):
# para = para.lower()
# if para == u'ok':
# return True
# return False
# class CitesDetector:
# """XXX TODO
# * unitttest :)
# * limit search citations according to UTC date
# * skip block under a reasonable size (['ok'])
# * normalize block text
# * enhance block detection (extract quote string in a first phase)
# """
# def _get_body(self, message):
# body = []
# for part in message.walk():
# if part.get_content_maintype() == 'text':
# payload = part.get_payload(decode=True)
# if part.get_content_type().endswith('html'):
# payload = remove_html_tags(payload)
# body.append(payload)
# elif part.get_content_type() == 'application/octet-stream':
# body.append(u'attached file: %s (%s)' %
# (part.get_filename(''), part.get_content_type()))
# elif part.get_content_type() == 'multipart/mixed':
# pass
# return u'\n\n--- part ---\n\n'.join(body)
# def _parse_mailbox(self, mailbox):
# """ don't match
# """
# for message in mailbox:
# body = self._get_body(message)
# yield parse_body(body)
# def process_mailbox(self, filename):
# """
# """
# mboxfile = open(filename)
# mbox = UnixMailbox(mboxfile, message_from_file)
# msgs = list(self._parse_mailbox(mbox))
# mboxfile.close()
# cites = {}
# for index, msg in enumerate(msgs):
# for index2, msg2 in enumerate(msgs):
# if index == index2 :
# continue
# for cite in msg.cites:
# if ignore_cite(cite):
# continue
# for para in msg2.content:
# if cite in para:
# cites.setdefault((index,index2), [])
# cites[(index, index2)].append( (cite, para) )
# return msgs, cites
# if __name__ == '__main__':
# from pprint import pprint
# msgs, cites = CitesDetector().process_mailbox(sys.argv[1])
# for index, msg in enumerate(msgs):
# print '*'*80, index
# pprint(msg.content)
# pprint(msg.cites)
# print
# keys = cites.keys()
# keys.sort()
# for key in keys:
# print '='*80, key
# pprint( cites[key] )
"""entity classes for entity types provided by the cubicweb email package
:organization: Logilab
:copyright: 2003-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""
__docformat__ = "restructuredtext en"
import re
from logilab.common import umessage
from cubicweb.interfaces import ITree
from cubicweb.common.mixins import TreeMixIn
from cubicweb.entities import AnyEntity, fetch_config
from cubes.email.emailcites import parse_body
class Email(TreeMixIn, AnyEntity):
"""customized class for Email entities"""
id = 'Email'
fetch_attrs, fetch_order = fetch_config(['subject'])
__rtags__ = {'attachment' : 'create',
}
__implements__ = AnyEntity.__implements__ + (ITree,)
widgets = {
'subject' : "StringWidget",
}
tree_attribute = 'reply_to'
def dc_title(self):
return self.subject
@property
def senderaddr(self):
return self.sender[0]
@property
def in_reply_to(self):
return self.reply_to and self.reply_to[0]
@property
def thread(self):
return self.in_thread and self.in_thread[0]
def parts_in_order(self, prefered_mime_type='text/html'):
"""sort an email parts in order, selecting among alternatives according to a
prefered mime type
"""