[csw-devel] SF.net SVN: gar:[20536] csw/mgar/gar/v2/lib/python/models.py

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Fri Mar 29 18:56:26 CET 2013


Revision: 20536
          http://gar.svn.sourceforge.net/gar/?rev=20536&view=rev
Author:   wahwah
Date:     2013-03-29 17:56:25 +0000 (Fri, 29 Mar 2013)
Log Message:
-----------
pkgdb: Handle pickled datetime.

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/models.py

Modified: csw/mgar/gar/v2/lib/python/models.py
===================================================================
--- csw/mgar/gar/v2/lib/python/models.py	2013-03-29 16:50:43 UTC (rev 20535)
+++ csw/mgar/gar/v2/lib/python/models.py	2013-03-29 17:56:25 UTC (rev 20536)
@@ -9,6 +9,7 @@
 from sqlobject import sqlbuilder
 import cjson
 import cPickle
+import datetime
 
 class Error(Exception):
   """Generic error."""
@@ -316,13 +317,18 @@
     #  - self.maintainer_id
     #  - GetVendorUrl unpickles the object (very slow)
     #  - GetSvnUrl unpickles the object (very slow)
+    def SanitizeDatetime(d):
+      if isinstance(d, datetime.datetime):
+       return d.isoformat()
+      else:
+       return d
     data = {
         'basename': self.basename,
         # For compatibility with the catalog parser from catalog.py
         'file_basename': self.basename,
         'catalogname': self.catalogname,
         'md5_sum': self.md5_sum,
-        'mtime': self.mtime,
+        'mtime': SanitizeDatetime(self.mtime),
         'rev': self.rev,
         'size': self.size,
         'version_string': self.version_string,

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list