Skip to content
Permalink
Browse files

Long term fix for the 1.2.8 App Engine update that broke Bloog code

  • Loading branch information...
mdragon committed Dec 4, 2009
1 parent 050f333 commit eb99d911bc9da32f35bf5e224b7cc923ce05f381
Showing with 30 additions and 4 deletions.
  1. +29 −2 models/__init__.py
  2. +1 −2 view.py
@@ -118,13 +118,30 @@ def to_json(self, attr_list=[]):
def to_entity(entity):
"""Convert datastore types in entity to
JSON-friendly structures."""
self._to_entity(entity)
my_to_entity(self, entity)
for skipped_property in self.__class__.json_does_not_include:
del entity[skipped_property]
replace_datastore_types(entity)
values = to_dict(self, attr_list, to_entity)
return simplejson.dumps(values)

def my_to_entity(self, entity):
"""Copies information from this model to provided entity.
Args:
entity: Entity to save information on.
"""
for prop in self.properties().values():
logging.debug("copying prop: " + prop.name)
datastore_value = prop.get_value_for_datastore(self)
if datastore_value == []:
try:
del entity[prop.name]
except KeyError:
pass
else:
entity[prop.name] = datastore_value

class MemcachedModel(SerializableModel):
"""MemcachedModel adds memcached all() retrieval through list().
@@ -147,9 +164,19 @@ def put(self):
memcache.delete(self.__class__.memcache_key())
return key

def to_entity(entity):
"""Convert datastore types in entity to
JSON-friendly structures."""
self._to_entity(entity)
logging.debug(dir(self.__class__))
for skipped_property in self.__class__.json_does_not_include:
del entity[skipped_property]
replace_datastore_types(entity)
values = to_dict(self, attr_list, to_entity)

def _to_repr(self):
return repr(to_dict(self, self.__class__.list_includes,
self._to_entity))
my_to_entity(self)))

@classmethod
def get_or_insert(cls, key_name, **kwds):
@@ -169,8 +169,7 @@ def full_render(self, handler, template_info, more_params):
NUM_FULL_RENDERS[path] = 0
NUM_FULL_RENDERS[path] += 1 # This lets us see % of cached views
# in /admin/timings (see timings.py)
#tags = Tag.list()
tags = None
tags = Tag.list()
years = Year.get_all_years()

# Define some parameters it'd be nice to have in views by default.

0 comments on commit eb99d91

Please sign in to comment.
You can’t perform that action at this time.