Skip to content
Browse files

DateProperty now support on serialization and deserialization.

  • Loading branch information...
1 parent 2c787b7 commit 0a26df0fc95910bc200aa25f454f915af320367b @tombatron committed Sep 16, 2012
Showing with 6 additions and 5 deletions.
  1. +4 −4 models.py
  2. +2 −1 python_testing/model_tests.py
View
8 models.py
@@ -1,9 +1,9 @@
from datetime import datetime
from google.appengine.api import memcache
-from google.appengine.ext.ndb import model, DateProperty
+from google.appengine.ext.ndb import model
import math
from google.appengine.ext.ndb.model import BooleanProperty, DateTimeProperty, \
- KeyProperty, StringProperty, TextProperty
+ KeyProperty, StringProperty, TextProperty, DateProperty
from libs import markdown2
import configuration
from utils import get_randomish_string, get_route
@@ -85,15 +85,15 @@ def _handle_value(element_name, repeated=False,
type_conversion=(lambda val:
model.Key(urlsafe=val)))
- if isinstance(model_prop, DateProperty):
+ if isinstance(model_prop, DateProperty) and model_prop.__class__.__name__ == 'DateProperty':
sanitized_dict[key] = _handle_value(
key,
repeated=model_prop._repeated,
type_conversion=(lambda val:
datetime.strptime(val, '%Y-%m-%d'))
)
- if isinstance(model_prop, DateTimeProperty):
+ if isinstance(model_prop, DateTimeProperty) and model_prop.__class__.__name__ == 'DateTimeProperty':
sanitized_dict[key] = _handle_value(
key,
repeated=model_prop._repeated,
View
3 python_testing/model_tests.py
@@ -277,7 +277,8 @@ def test_post_date_only_automatically_set_upon_first_save_on_entity(self):
author=self.test_author
).put().get()
- foo_post
+ foo_post.post_date = datetime(2012, 5, 1)
+ foo_post.put()
self.assertNotEqual(foo_post.last_modified_on, foo_post.post_date)

0 comments on commit 0a26df0

Please sign in to comment.
Something went wrong with that request. Please try again.