summaryrefslogtreecommitdiff
path: root/django/utils/datastructures.py
diff options
context:
space:
mode:
authorAnton Baklanov <antonbaklanov@gmail.com>2013-04-17 18:20:31 +0300
committerClaude Paroz <claude@2xlibre.net>2013-04-19 10:08:16 +0200
commit59d127e45f5ed31e346162a0ac312f672c096821 (patch)
tree2b89e419f1d7e69ce93aad0412b9061162c9edfe /django/utils/datastructures.py
parentbfe25de42993fdbfccd4759f48ac6694e1ed32d9 (diff)
downloaddjango-59d127e45f5ed31e346162a0ac312f672c096821.tar.gz
Fixed #20276 -- Implemented __bool__ for MergeDict
MergeDict evaluates now to False if all contained dicts are empty. Thanks til for the report and the initial patch.
Diffstat (limited to 'django/utils/datastructures.py')
-rw-r--r--django/utils/datastructures.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py
index 64c218fe43..b3060202be 100644
--- a/django/utils/datastructures.py
+++ b/django/utils/datastructures.py
@@ -14,6 +14,12 @@ class MergeDict(object):
def __init__(self, *dicts):
self.dicts = dicts
+ def __bool__(self):
+ return any(self.dicts)
+
+ def __nonzero__(self):
+ return type(self).__bool__(self)
+
def __getitem__(self, key):
for dict_ in self.dicts:
try: