[icalendar-dev] problem pickling event instances (with patch!)

Gene Cash gcash at cfl.rr.com
Tue Oct 9 00:34:07 CEST 2007


It turns out if you try picking event instances, you get:

cPickle.PicklingError: Can't pickle <class 'icalendar.prop.UTC'>: it's 
not the same object as icalendar.prop.UTC

This is because of line 228 in prop.py, which turns the UTC class into 
an instance, thus confusing pickle. The simple fix is to simply rename 
the class:

--- prop.py.orig        2007-10-08 18:21:07.000000000 -0400
+++ prop.py     2007-10-08 18:11:57.000000000 -0400
@@ -211,24 +211,24 @@
          return self.__name

      def dst(self, dt):
          return ZERO


-class UTC(tzinfo):
+class UTC_class(tzinfo):
      """UTC tzinfo subclass"""

      def utcoffset(self, dt):
          return ZERO

      def tzname(self, dt):
          return "UTC"

      def dst(self, dt):
          return ZERO
-UTC = UTC()
+UTC = UTC_class()

  class LocalTimezone(tzinfo):
      """
      Timezone of the machine where the code is running
      """

I can't see this breaking anything. I'm using Python 2.5.1

I'm writing a calendar app for my Nokia N800 (see 
http://home.cfl.rr.com/genecash/nokia/index.html)

Event objects are nifty and useful, so after I import an iCal file I'm 
using a dictionary of events keyed by GUID as part of my internal 
calender representation. It makes "syncing" to multiple sources of 
calendar info easier. I have at least 3 brain-dead scheduling apps I 
must use daily, but at least all of them can speak RFC 2445, so this is 
important. It's still pre-alpha but you might want to look at the code.

Thanks for writing a really nice piece of software. Well done.

-gc

-- 
Is this my glass? Is it? Does it *look* like my glass? No. *My* glass 
was bigger. And full.


More information about the icalendar-dev mailing list