[Zope3-dev] datetime module

Marius Gedminas mgedmin@codeworks.lt
Thu, 7 Nov 2002 12:15:38 +0200


Hi,

I'm trying to use datetime module in a Zope3 project.  There are at least
two problems with that module:

- date/time objects cannot be pickled, betcause datetime.basetime
  defines an empty __slots__ but doesn't define __getstate__.  For all
  __slots__ using objects Python provides a default 'bozo' __getstate__
  which throws a TypeError ("a class that defines __slots__ without
  defining __getstate__ cannot be pickled").

  Adding a simple

    def __getstate__(self):
        return self.__dict__

  to datetime.basetime solves this problem.  Is this the right fix?
  Should I commit it to Zope3 CVS?

- date/time objects are inaccessible from untrusted code (e.g. you
  cannot do a somedateobject.isoformat() from a page template).  Should
  there be appropriate security declarations somewhere in the
  configure.zcml forest, or should these date/time objects be kept
  unwrapped like objects of Python builtin types?

Marius Gedminas
-- 
"Linux: the operating system with a CLUE... Command Line User Environment".
(seen in a posting in comp.software.testing)