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

update for cw 3.5 api (identical_to/canonical changed to prefered_form)

parent 653af668a1e0
......@@ -11,7 +11,7 @@ Package: cubicweb-email
Architecture: all
Conflicts: erudi-blog, erudi-blog-server, erudi-blog-client, erudi-blog-comp
Replaces: erudi-blog, erudi-blog-server, erudi-blog-client, erudi-blog-comp
Depends: cubicweb-common (>= 3.2.0), cubicweb-file
Depends: cubicweb-common (>= 3.5.0), cubicweb-file
Description: email component for the CubicWeb framework
This CubicWeb component models email messages.
.
......
......@@ -201,7 +201,7 @@ class MBOXImporter:
self._alternatives[-1].append(parteid)
def address_eid(self, address, alias=None):
rql = 'Any X,CF WHERE X is EmailAddress, X address %(addr)s, X canonical CF'
rql = 'Any X WHERE X is EmailAddress, X address %(addr)s'
rset = self.execute(rql, {'addr': address})
if not rset:
address = address.lower()
......@@ -213,12 +213,9 @@ class MBOXImporter:
rset = self.execute('INSERT EmailAddress X: X address %(addr)s, X alias %(alias)s',
{'addr': address, 'alias': alias})
self._notify_created('emailaddress', rset[0][0])
elif not rset[0][1]:
# check for a canonical form if any
entity = rset.get_entity(0, 0)
cnentity = entity.canonical_form()
if cnentity:
return cnentity.eid
else:
# check for a prefered form if any
return rset.get_entity(0, 0).prefered.eid
return rset[0][0]
def thread_eid(self, subject, replyeid):
......
......@@ -116,9 +116,9 @@ W0201: 5:C.set: Attribute '__value' defined outside __init__
W0201: 6:C.set: Attribute '__length' defined outside __init__
===
Although strictly speaking they are indeed defined outside __init__, these
fields are guaranteed to be initialised when an object of type C is
constructed. It would be useful if pylint could recognise situations like
Although strictly speaking they are indeed defined outside __init__, these
fields are guaranteed to be initialised when an object of type C is
constructed. It would be useful if pylint could recognise situations like
this one and not issue this warning.
Bye,
......@@ -195,8 +195,8 @@ http://lists.logilab.org/mailman/listinfo/python-projects
def test_address_detection(self):
# test both case normalization and canonicalization of email address
eid1 = self.execute('INSERT EmailAddress X: X address "maarten.ter.huurne@philips.com"')[0][0]
eid2 = self.execute('INSERT EmailAddress X: X address "maarten@philips.com", X canonical TRUE')[0][0]
self.execute('SET X identical_to Y WHERE X eid %s, Y eid %s' % (eid1, eid2))
eid2 = self.execute('INSERT EmailAddress X: X address "maarten@philips.com"')[0][0]
self.execute('SET X prefered_form Y WHERE X eid %s, Y eid %s' % (eid1, eid2))
#self.assertEquals(env.vreg.schema['identical_to'].symetric, True)
#ea1 = cursor.execute('Any X WHERE X eid %s' % eid2).get_entity(0, None)
#self.assertEquals(ea1.canonical, True)
......@@ -213,10 +213,8 @@ http://lists.logilab.org/mailman/listinfo/python-projects
self.assertEquals(len(rset), 1)
email = rset.get_entity(0, 0)
self.assertEquals(email.sender[0].address, 'maarten@philips.com')
if __name__ == '__main__':
unittest_main()
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