summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pykolab.spec.in2
-rw-r--r--pykolab/setup/setup_mta.py5
-rw-r--r--pykolab/xml/event.py59
-rw-r--r--tests/test-003-event.py24
-rw-r--r--wallace/module_resources.py2
5 files changed, 76 insertions, 16 deletions
diff --git a/pykolab.spec.in b/pykolab.spec.in
index 5f69b96..2bcd8cd 100644
--- a/pykolab.spec.in
+++ b/pykolab.spec.in
@@ -377,6 +377,8 @@ rm -rf %{buildroot}
%{_sysconfdir}/sysconfig/wallace
%{_sbindir}/wallaced
%{python_sitelib}/wallace
+%attr(%{kolab_user},%{kolab_group},0700) %dir %{_var}/spool/pykolab
+%attr(%{kolab_user},%{kolab_group},0700) %dir %{_var}/spool/pykolab/wallace
%changelog
* @DATESTAMP@ Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> @VERSION@-@RELEASE@
diff --git a/pykolab/setup/setup_mta.py b/pykolab/setup/setup_mta.py
index ebcca2f..452b2b4 100644
--- a/pykolab/setup/setup_mta.py
+++ b/pykolab/setup/setup_mta.py
@@ -49,6 +49,8 @@ def execute(*args, **kw):
if user_filter == None:
user_filter = conf.get('ldap','user_filter')
+ resource_filter = conf.get('ldap', 'resource_filter')
+
files = {
"/etc/postfix/ldap/local_recipient_maps.cf": """
server_host = localhost
@@ -62,7 +64,7 @@ domain = ldap:/etc/postfix/ldap/mydestination.cf
bind_dn = %(service_bind_dn)s
bind_pw = %(service_bind_pw)s
-query_filter = (&(|(mail=%%s)(alias=%%s))(|%(kolab_user_filter)s%(kolab_group_filter)s))
+query_filter = (&(|(mail=%%s)(alias=%%s))(|%(kolab_user_filter)s%(kolab_group_filter)s%(resource_filter)s))
result_attribute = mail
""" % {
"base_dn": conf.get('ldap', 'base_dn'),
@@ -70,6 +72,7 @@ result_attribute = mail
"service_bind_pw": conf.get('ldap', 'service_bind_pw'),
"kolab_user_filter": user_filter,
"kolab_group_filter": group_filter,
+ "resource_filter": resource_filter,
},
"/etc/postfix/ldap/mydestination.cf": """
server_host = localhost
diff --git a/pykolab/xml/event.py b/pykolab/xml/event.py
index 7a1c2e7..d2973aa 100644
--- a/pykolab/xml/event.py
+++ b/pykolab/xml/event.py
@@ -3,6 +3,7 @@ import icalendar
from icalendar import vDatetime
from icalendar import vText
import kolabformat
+import pytz
import time
import uuid
@@ -390,19 +391,36 @@ class Event(object):
year,
month,
day,
- hour,
- minute,
- second
) = (
_datetime.year(),
_datetime.month(),
_datetime.day(),
- _datetime.hour(),
- _datetime.minute(),
- _datetime.second()
)
- return datetime.datetime(year, month, day, hour, minute, second)
+ if not _datetime.hour() == None and not _datetime.hour() < 0:
+ (
+ hour,
+ minute,
+ second
+ ) = (
+ _datetime.hour(),
+ _datetime.minute(),
+ _datetime.second()
+ )
+
+ _timezone = _datetime.timezone()
+
+ if _timezone == '':
+ _timezone = pytz.utc
+ elif _timezone == None:
+ _timezone = pytz.utc
+ else:
+ _timezone = pytz.timezone(_timezone)
+
+ if _datetime.hour() == None or _datetime.hour() < 0:
+ return datetime.date(year, month, day)
+ else:
+ return datetime.datetime(year, month, day, hour, minute, second, tzinfo=_timezone)
def get_status(self):
status = self.event.status()
@@ -485,6 +503,10 @@ class Event(object):
valid_datetime = True
if isinstance(_datetime, datetime.datetime):
+ # If no timezone information is passed on, make it UTC
+ if _datetime.tzinfo == None:
+ _datetime = _datetime.replace(tzinfo=pytz.utc)
+
valid_datetime = True
if not valid_datetime:
@@ -509,12 +531,14 @@ class Event(object):
_datetime.minute,
_datetime.second
)
+ _cdatetime = kolabformat.cDateTime(year, month, day, hour, minute, second)
else:
- (hour, minute, second) = (0,0,0)
+ _cdatetime = kolabformat.cDateTime(year, month, day)
- self.event.setEnd(
- kolabformat.cDateTime(year, month, day, hour, minute, second)
- )
+ if hasattr(_datetime, "tzinfo"):
+ _cdatetime.setTimezone(_datetime.tzinfo.__str__())
+
+ self.event.setEnd(_cdatetime)
def set_from_ical(self, attr, value):
if attr == "dtend":
@@ -663,11 +687,16 @@ class Event(object):
self.event.setPriority(priority)
def set_start(self, _datetime):
+
valid_datetime = False
if isinstance(_datetime, datetime.date):
valid_datetime = True
if isinstance(_datetime, datetime.datetime):
+ # If no timezone information is passed on, make it UTC
+ if _datetime.tzinfo == None:
+ _datetime = _datetime.replace(tzinfo=pytz.utc)
+
valid_datetime = True
if not valid_datetime:
@@ -692,10 +721,14 @@ class Event(object):
_datetime.minute,
_datetime.second
)
+ _cdatetime = kolabformat.cDateTime(year, month, day, hour, minute, second)
else:
- (hour, minute, second) = (0,0,0)
+ _cdatetime = kolabformat.cDateTime(year, month, day)
+
+ if hasattr(_datetime, "tzinfo"):
+ _cdatetime.setTimezone(_datetime.tzinfo.__str__())
- self.event.setStart(kolabformat.cDateTime(year, month, day, hour, minute, second))
+ self.event.setStart(_cdatetime)
def set_status(self, status):
if status in self.status_map.keys():
diff --git a/tests/test-003-event.py b/tests/test-003-event.py
index 031f4a1..c18523a 100644
--- a/tests/test-003-event.py
+++ b/tests/test-003-event.py
@@ -1,4 +1,6 @@
import datetime
+import pytz
+import sys
import unittest
from pykolab.xml import Attendee
@@ -14,7 +16,7 @@ class TestEventXML(unittest.TestCase):
self.assertRaises(EventIntegrityError, self.event.__str__)
def test_001_minimal(self):
- self.event.set_start(datetime.datetime.now())
+ self.event.set_start(datetime.datetime.now(pytz.timezone("Europe/London")))
self.assertIsInstance(self.event.get_start(), datetime.datetime)
self.assertIsInstance(self.event.__str__(), basestring)
@@ -73,5 +75,25 @@ class TestEventXML(unittest.TestCase):
self.event.delegate("jane@doe.org", "john@doe.org")
self.assertEqual(len(self.event.get_attendee("jane@doe.org").get_delegated_to()), 2)
+ def test_015_timezone(self):
+ _tz = self.event.get_start()
+ self.assertIsInstance(_tz.tzinfo, datetime.tzinfo)
+
+ def test_016_start_with_timezone(self):
+ _start = datetime.datetime(2012, 05, 23, 11, 58, 00, tzinfo=pytz.timezone("Europe/Zurich"))
+ _start_utc = _start.astimezone(pytz.utc)
+ self.assertEqual(_start.__str__(), "2012-05-23 11:58:00+01:00")
+ self.assertEqual(_start_utc.__str__(), "2012-05-23 10:58:00+00:00")
+ self.event.set_start(_start)
+ self.assertIsInstance(_start.tzinfo, datetime.tzinfo)
+ self.assertEqual(_start.tzinfo, pytz.timezone("Europe/Zurich"))
+
+ def test_017_allday_without_timezone(self):
+ _start = datetime.date(2012, 05, 23)
+ self.assertEqual(_start.__str__(), "2012-05-23")
+ self.event.set_start(_start)
+ self.assertEqual(hasattr(_start,'tzinfo'), False)
+ self.assertEqual(self.event.get_start().__str__(), "2012-05-23")
+
if __name__ == '__main__':
unittest.main()
diff --git a/wallace/module_resources.py b/wallace/module_resources.py
index 1641be1..c5b145f 100644
--- a/wallace/module_resources.py
+++ b/wallace/module_resources.py
@@ -463,7 +463,7 @@ def itip_events_from_message(message):
)
else:
- log.error(_("Non-multipart iTip messages are not accepted"))
+ log.debug(_("Message is not an iTip message (non-multipart message)"), level=5)
return itip_events