| Index: appengine_django/serializer/xml.py |
| =================================================================== |
| --- appengine_django/serializer/xml.py (revision 19) |
| +++ appengine_django/serializer/xml.py (working copy) |
| @@ -20,6 +20,8 @@ |
| ToXml method for each entity. |
| """ |
| +import datetime |
| +import time |
| import re |
| from django.conf import settings |
| @@ -30,7 +32,9 @@ |
| from google.appengine.api import datastore_types |
| from google.appengine.ext import db |
| -from python import FakeParent |
| +from appengine_django.serializer.python import FakeParent |
| +from appengine_django.serializer.python import DATE_FORMAT |
| +from appengine_django.serializer.python import TIME_FORMAT |
| getInnerText = xml_serializer.getInnerText |
| @@ -133,9 +137,20 @@ |
| raise base.DeserializationError(u"Cannot load Reference with " |
| "unnamed key: '%s'" % field_value) |
| data[field.name] = key_obj |
| - else: |
| - data[field.name] = field.validate(field_value) |
| + continue |
| + if isinstance(field, db.DateTimeProperty): |
|
GvR
2008/05/13 16:40:54
Why the duplicated code? I guess this is another
|
| + try: |
| + t = time.strptime(field_value.split(".")[0], |
| + "%s %s"% (DATE_FORMAT, TIME_FORMAT)) |
| + d = datetime.datetime(*(t)[0:6]) |
| + field_value = d |
| + except (ValueError, TypeError), e: |
| + # Pass it on anyway, and hope the model can deal with it. |
| + pass |
| + |
| + data[field.name] = field.validate(field_value) |
| + |
| # Create the new model instance with all it's data, but no parent. |
| object = Model(**data) |
| # Now add the parent into the hidden attribute, bypassing the type checks |