BUG?: kopano-python: restrictions in folders not working
-
Very simple example:
#!/usr/bin/env python2 # -*- coding: utf-8 -*- import kopano import MAPI # Kopano Server, User and Password kopano_server = 'http://xxxxx.net:236/kopano' kopano_user = 'xxx' kopano_password = 'xxx' # Connect to kopano server = kopano.Server(server_socket=kopano_server, auth_user=kopano_user, auth_pass=kopano_password) store = server.user(kopano_user).store folder = store.folder('Sent Items') restriction = MAPI.Struct.SContentRestriction(MAPI.FL_SUBSTRING, MAPI.Tags.PR_SUBJECT_W, MAPI.Struct.SPropValue(MAPI.Tags.PR_SUBJECT_W, str('Your Ref'))) mails = folder.items(restriction) for mail in mails: print(mail.subject)
fails with
Traceback (most recent call last): File "./example.py", line 20, in <module> for mail in mails: File "/usr/lib/python2.7/site-packages/kopano/folder.py", line 364, in items restriction=restriction, File "/usr/lib/python2.7/site-packages/kopano/table.py", line 46, in __init__ self.mapitable.Restrict(restriction.mapiobj, TBL_BATCH) AttributeError: SContentRestriction instance has no attribute 'mapiobj'
This seems to be a bug. Can anybody comment on this? It is a major limitation to the advanced use of the python module. Whether python 2 or 3 does not matter, I have tried both. Current stable version (8.7.17).
-
I think you mix the low level MAPI object (SContentRestriction) with high level folder API. There is a
kopano.Restriction
class.So try something like
mails = folder.items(kopano.Restriction(restriction))
-
Thanks, that did it!