Adds methods for [] & len into LazyURLPattern
The Django 404 page currently depends on being able to call len() and index LazyURLPattern. However, the special methods for doing this (__len__() and __getitem__()) are not forwarded to the object wrapped by SimpleLazyObject by default. Thus, methods to foward these special methods to the wrapped object have been implemented in LazyURLPattern. Fixes: bug 1183578 Change-Id: I133e97ed66180fe78cfe1b7fd9c86bac4171a994
This commit is contained in:
parent
24d9f140f5
commit
cc87269b4a
@ -561,6 +561,16 @@ class LazyURLPattern(SimpleLazyObject):
|
||||
self._setup()
|
||||
return reversed(self._wrapped)
|
||||
|
||||
def __len__(self):
|
||||
if self._wrapped is empty:
|
||||
self._setup()
|
||||
return len(self._wrapped)
|
||||
|
||||
def __getitem__(self, idx):
|
||||
if self._wrapped is empty:
|
||||
self._setup()
|
||||
return self._wrapped[idx]
|
||||
|
||||
|
||||
class Site(Registry, HorizonComponent):
|
||||
""" The overarching class which encompasses all dashboards and panels. """
|
||||
|
Loading…
x
Reference in New Issue
Block a user