summaryrefslogtreecommitdiffstats
path: root/wallace/module_resources.py
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-07-07 18:43:25 -0400
committerThomas Bruederli <bruederli@kolabsys.com>2014-07-07 18:43:25 -0400
commita674289628249f45ec46c3096b1c476692943ff3 (patch)
tree56a6085d94514a2098eaca41e847e39cb50e693a /wallace/module_resources.py
parent6e137a89f6f29975133633e2e70557b3954d4220 (diff)
downloadpykolab-a674289628249f45ec46c3096b1c476692943ff3.tar.gz
Use new pykolab.xml.event_from_message() function in wallace modules and verify that attachments survive event updates
Diffstat (limited to 'wallace/module_resources.py')
-rw-r--r--wallace/module_resources.py39
1 files changed, 20 insertions, 19 deletions
diff --git a/wallace/module_resources.py b/wallace/module_resources.py
index f398120..3864f7c 100644
--- a/wallace/module_resources.py
+++ b/wallace/module_resources.py
@@ -40,8 +40,8 @@ import kolabformat
from pykolab.auth import Auth
from pykolab.conf import Conf
from pykolab.imap import IMAP
-from pykolab.xml import event_from_string
from pykolab.xml import to_dt
+from pykolab.xml import event_from_message
from pykolab.itip import events_from_message
from pykolab.itip import check_event_conflict
from pykolab.translate import _
@@ -467,28 +467,29 @@ def read_resource_calendar(resource_rec, itip_events):
event_message = message_from_string(data[0][1])
- if event_message.is_multipart():
- for part in event_message.walk():
- if part.get_content_type() == "application/calendar+xml":
- payload = part.get_payload(decode=True)
- event = pykolab.xml.event_from_string(payload)
+ try:
+ event = event_from_message(message_from_string(data[0][1]))
+ except Exception, e:
+ log.error(_("Failed to parse event from message %s/%s: %r") % (mailbox, num, e))
+ continue
- for itip in itip_events:
- conflict = check_event_conflict(event, itip)
+ if event:
+ for itip in itip_events:
+ conflict = check_event_conflict(event, itip)
- if event.get_uid() == itip['uid']:
- resource_rec['existing_events'].append(itip['uid'])
+ if event.get_uid() == itip['uid']:
+ resource_rec['existing_events'].append(itip['uid'])
- if conflict:
- log.info(
- _("Event %r conflicts with event %r") % (
- itip['xml'].get_uid(),
- event.get_uid()
- )
- )
+ if conflict:
+ log.info(
+ _("Event %r conflicts with event %r") % (
+ itip['xml'].get_uid(),
+ event.get_uid()
+ )
+ )
- resource_rec['conflicting_events'].append(event.get_uid())
- resource_rec['conflict'] = True
+ resource_rec['conflicting_events'].append(event.get_uid())
+ resource_rec['conflict'] = True
return num_messages