def get_storage_hash(self, storage):
"""
Return a hex string hash for a storage object (or string containing a
pickle of a storage object).
"""
try:
# Make sure that pickle is getting a string, since it can choke
# with unicode.
storage_obj = pickle.loads(str(self.pickle))
except:
# We need to return some storage, and if there's an exception then
# it is most likely the default_storage (since that fails with a
# recursion error due to LazyObject "awesomeness").
storage_obj = default_storage
storage_cls = storage_obj.__class__
name = '%s.%s' % (storage_cls.__module__, storage_cls.__name__)
return hashlib.md5(name).hexdigest()
评论列表
文章目录