Module server.weakattr

Helpers for non-owned object attributes

Classes

class WeakAttribute

Transparently allow an object attribute to reference another object via a weak reference.

Expand source code
def __get__(self, obj: object, objclass: type) -> Optional[T]:
    ref = obj.__dict__.get(self.name)
    if ref:
        return ref()
    return None

Ancestors

  • typing.Generic