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

some 3.6 api update

parent 19fba397f9ed
......@@ -11,7 +11,7 @@ import re
from logilab.common import umessage
from cubicweb.interfaces import ITree
from cubicweb.common.mixins import TreeMixIn
from cubicweb.mixins import TreeMixIn
from cubicweb.entities import AnyEntity, fetch_config
from import parse_body
......@@ -19,7 +19,7 @@ from import parse_body
class Email(TreeMixIn, AnyEntity):
"""customized class for Email entities"""
id = 'Email'
__regid__ = 'Email'
fetch_attrs, fetch_order = fetch_config(['subject'])
__implements__ = AnyEntity.__implements__ + (ITree,)
......@@ -100,7 +100,7 @@ class Email(TreeMixIn, AnyEntity):
class EmailPart(AnyEntity):
"""customized class for EmailPart entities"""
id = 'EmailPart'
__regid__ = 'EmailPart'
def dc_title(self):
return '%s (%s %s)' % (,
......@@ -126,7 +126,7 @@ class EmailPart(AnyEntity):
class EmailThread(AnyEntity):
"""customized class for EmailThread entities"""
id = 'EmailThread'
__regid__ = 'EmailThread'
fetch_attrs, fetch_order = fetch_config(['title'])
def dc_title(self):
......@@ -15,9 +15,9 @@ import re
from logilab.mtconverter import TransformError
from cubicweb import UnknownEid
from cubicweb.server.pool import PreCommitOperation
from cubicweb.server.hooksmanager import Hook
from cubicweb.common.mail import parse_message_id
from cubicweb.mail import parse_message_id
from cubicweb.selectors import entity_implements
from cubicweb.server import hook
def fix_ownership(session, eid, email):
......@@ -31,7 +31,7 @@ def fix_ownership(session, eid, email):
{'x': eid, 'u': sender.eid}, 'x')
class ExtractEmailInformation(PreCommitOperation):
class ExtractEmailInformation(hook.Operation):
"""generate a comment on the original entity if supported"""
def precommit_event(self):
......@@ -67,7 +67,7 @@ class ExtractEmailInformation(PreCommitOperation):
fix_ownership(self.session, com[0][0],
class ExtractEmailChangeState(PreCommitOperation):
class ExtractEmailChangeState(hook.Operation):
"""check if there are some change state instruction in the mail content"""
instr_rgx = re.compile(':(\w+):\s*#?(\d+)', re.U)
......@@ -108,19 +108,20 @@ class ExtractEmailChangeState(PreCommitOperation):
fix_ownership(self.session, trinfo.eid,
class AddEmailHook(Hook):
class AddEmailHook(hook.Hook):
"""an email has been added, check if associated content should be created
__regid__ = 'extractmailcontent'
__select__ = hook.Hook.__select__ & entity_implements('Email')
events = ('after_add_entity',)
accepts = ('Email',)
def call(self, session, entity):
if 'comments' in session.repo.schema:
for msgid in entity.references():
def __call__(self):
if 'comments' in self._cw.repo.schema:
for msgid in self.entity.references():
info = parse_message_id(msgid, self.config.appid)'extracted information from message id %s: %s',
msgid, info)
if info:
ExtractEmailInformation(session, email=entity, info=info)
ExtractEmailInformation(self._cw, email=self.entity, info=info)
ExtractEmailChangeState(session, email=entity)
ExtractEmailChangeState(self._cw, email=self.entity)
......@@ -40,7 +40,7 @@ class Email(EntityType):
class EmailPart(EntityType):
"""an email attachment"""
permissions = {
__permissions__ = {
'read': ('managers', 'users', 'guests',), # XXX if E parts X, U has_read_permission E
'add': ('managers', ERQLExpression('E parts X, U has_update_permission E'),),
'delete': ('managers', ERQLExpression('E parts X, U has_update_permission E')),
......@@ -10,8 +10,8 @@ _ = unicode
from logilab.mtconverter import xml_escape
from cubicweb.selectors import implements
from cubicweb.common.uilib import soup2xhtml
from cubicweb.common.mixins import TreeViewMixIn
from cubicweb.uilib import soup2xhtml
from cubicweb.mixins import TreeViewMixIn
from cubicweb.web import uicfg, formwidgets
from cubicweb.web.views import baseviews, primary
......@@ -74,7 +74,7 @@ class EmailPrimaryView(primary.PrimaryView):
class EmailHeadersView(baseviews.EntityView):
"""display email's headers"""
id = 'headers'
__regid__ = 'headers'
__select__ = implements('Email')
title = _('headers')
templatable = False
......@@ -112,13 +112,13 @@ class EmailOneLineView(baseviews.OneLineView):
class EmailOutOfContextView(EmailOneLineView):
"""short view outside the context of the email"""
id = 'outofcontext'
__regid__ = 'outofcontext'
title = _('out of context')
class EmailInContextView(EmailOneLineView):
"""short view inside the context of the email"""
id = 'incontext'
__regid__ = 'incontext'
class EmailPartOutOfContextView(baseviews.OutOfContextView):
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