mirror of
https://github.com/django/django.git
synced 2025-09-18 00:10:22 +00:00
Fixed #12506 - 'lazy' fails when there are multiple expected classes with the same method
Thanks to Alex for report and patch git-svn-id: http://code.djangoproject.com/svn/django/trunk@12104 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
4d6c66d4d8
commit
bcef28349a
3 changed files with 16 additions and 1 deletions
|
@ -167,9 +167,13 @@ def lazy(func, *resultclasses):
|
|||
for resultclass in resultclasses:
|
||||
cls.__dispatch[resultclass] = {}
|
||||
for (k, v) in resultclass.__dict__.items():
|
||||
# All __promise__ return the same wrapper method, but they
|
||||
# also do setup, inserting the method into the dispatch
|
||||
# dict.
|
||||
meth = cls.__promise__(resultclass, k, v)
|
||||
if hasattr(cls, k):
|
||||
continue
|
||||
setattr(cls, k, cls.__promise__(resultclass, k, v))
|
||||
setattr(cls, k, meth)
|
||||
cls._delegate_str = str in resultclasses
|
||||
cls._delegate_unicode = unicode in resultclasses
|
||||
assert not (cls._delegate_str and cls._delegate_unicode), "Cannot call lazy() with both str and unicode return types."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue