Display embedded entities as JSON dictionaries
import cgi
import datetime
+import json
import math
import time
import types
@@ -273,6 +274,26 @@ class EmbeddedEntityType(BlobType):
def name(self):
return 'entity:proto'
+ def input_field(self, name, value, sample_values, back_uri):
+ if value is None:
+ return '&lt;null&gt;'
+
+ entity = datastore.Entity.FromPb(value)
+ try:
+ return json.dumps(entity)
+ except TypeError:
+ return '&lt;binary&gt;'
+
+ def format(self, value):
+ if value is None:
+ return '<null>'
+
+ entity = datastore.Entity.FromPb(value)
+ try:
+ return json.dumps(entity)
+ except TypeError:
+ return '<binary>'
+
class TimeType(DataType):
_FORMAT = '%Y-%m-%d %H:%M:%S'
