我们从Python开源项目中,提取了以下28个代码示例,用于说明如何使用django.utils.functional.LazyObject()。
def __init__(self, storage=None, *args, **kwargs): if storage is not None: self.storage = storage if self.storage is None: raise ImproperlyConfigured("The staticfiles storage finder %r " "doesn't have a storage class " "assigned." % self.__class__) # Make sure we have an storage instance here. if not isinstance(self.storage, (Storage, LazyObject)): self.storage = self.storage() super(BaseStorageFinder, self).__init__(*args, **kwargs)
def get_storage_hash(storage): """ Return a hex string hash for a storage object (or string containing 'full.path.ClassName' referring to a storage object). """ # If storage is wrapped in a lazy object we need to get the real thing. if isinstance(storage, LazyObject): if storage._wrapped is None: storage._setup() storage = storage._wrapped if not isinstance(storage, six.string_types): storage_cls = storage.__class__ storage = '%s.%s' % (storage_cls.__module__, storage_cls.__name__) return hashlib.md5(storage.encode('utf8')).hexdigest()