Ticket #15811: lazy.with_dir.patch

File lazy.with_dir.patch, 1.5 KB (added by Amirouche, 12 years ago)

git format

  • django/utils/functional.py

    diff --git a/django/utils/functional.py b/django/utils/functional.py
    index befe3e9..66667ad 100644
    a b def lazy(func, *resultclasses):  
    8181            cls.__dispatch = {}
    8282            for resultclass in resultclasses:
    8383                cls.__dispatch[resultclass] = {}
    84                 for type_ in reversed(resultclass.mro()):
    85                     for (k, v) in type_.__dict__.items():
    86                         # All __promise__ return the same wrapper method, but they
    87                         # also do setup, inserting the method into the dispatch
    88                         # dict.
    89                         meth = cls.__promise__(resultclass, k, v)
    90                         if hasattr(cls, k):
    91                             continue
    92                         setattr(cls, k, meth)
     84                for k in dir(resultclass):
     85                    v = getattr(resultclass, k)
     86                    # All __promise__ return the same wrapper method, but they
     87                    # also do setup, inserting the method into the dispatch
     88                    # dict.
     89                    meth = cls.__promise__(resultclass, k, v)
     90                    if hasattr(cls, k):
     91                        continue
     92                    setattr(cls, k, meth)
    9393            cls._delegate_str = str in resultclasses
    9494            cls._delegate_unicode = unicode in resultclasses
    9595            assert not (cls._delegate_str and cls._delegate_unicode), "Cannot call lazy() with both str and unicode return types."
Back to Top