Module server.weakattr

Helpers for non-owned object attributes

Classes

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

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

Ancestors

  • typing.Generic