Skip to content

Commit

Permalink
Long term fix for the 1.2.8 App Engine update that broke Bloog code
Browse files Browse the repository at this point in the history
  • Loading branch information
mdragon committed Dec 4, 2009
1 parent 050f333 commit eb99d91
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
31 changes: 29 additions & 2 deletions models/__init__.py
Expand Up @@ -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().
Expand All @@ -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):
Expand Down
3 changes: 1 addition & 2 deletions view.py
Expand Up @@ -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.
Expand Down

0 comments on commit eb99d91

Please sign in to comment.