Get rid of check_essentials hack

This commit is contained in:
Keith Mitchell
2012-03-27 13:17:48 -07:00
committed by Neil Williams
parent b391fd5dd5
commit 3e40a58d42
2 changed files with 9 additions and 13 deletions

View File

@@ -270,7 +270,7 @@ class DataThing(object):
self._cache_myself()
@classmethod
def _load_multi(cls, need, check_essentials=True):
def _load_multi(cls, need):
need = tup(need)
need_ids = [n._id for n in need]
datas = cls._get_data(cls._type_id, need_ids)
@@ -285,13 +285,9 @@ class DataThing(object):
i._t.update(datas.get(i._id, i._t))
i._loaded = True
for essential in essentials:
if essential not in i._t:
if check_essentials:
raise AttributeError("Refusing to cache %s; it's missing %s"
% (i._fullname, essential))
else:
print "Warning: %s is missing %s" % (i._fullname, essential)
for attr in essentials:
if attr not in i._t:
print "Warning: %s is missing %s" % (i._fullname, attr)
i._asked_for_data = True
to_save[i._id] = i
@@ -300,8 +296,8 @@ class DataThing(object):
#write the data to the cache
cache.set_multi(to_save, prefix=prefix)
def _load(self, check_essentials=True):
self._load_multi(self, check_essentials)
def _load(self):
self._load_multi(self)
def _safe_load(self):
if not self._loaded:
@@ -352,7 +348,7 @@ class DataThing(object):
#TODO error when something isn't found?
@classmethod
def _byID(cls, ids, data=False, return_dict=True, extra_props=None,
stale=False, check_essentials=True):
stale=False):
ids, single = tup(ids, True)
prefix = thing_prefix(cls.__name__)
@@ -387,7 +383,7 @@ class DataThing(object):
if not v._loaded:
need.append(v)
if need:
cls._load_multi(need, check_essentials)
cls._load_multi(need)
### The following is really handy for debugging who's forgetting data=True:
# else:
# for v in bases.itervalues():

View File

@@ -824,7 +824,7 @@ def fix_if_broken(thing, delete = True, fudge_links = False):
if not tried_loading:
tried_loading = True
thing._load(check_essentials=False)
thing._load()
try:
getattr(thing, attr)