class documentation

class MappedCollection(dict):

View In Hierarchy

A basic dictionary-based collection class.

Extends dict with the minimal bag semantics that collection classes require. set and remove are implemented in terms of a keying function: any callable that takes an object and returns an object for use as a dictionary key.

Method __init__ Create a new collection with keying provided by keyfunc.
Method remove Remove an item by value, consulting the keyfunc for the key.
Method set Add an item by value, consulting the keyfunc for the key.
Instance Variable keyfunc Undocumented
def __init__(self, keyfunc):

Create a new collection with keying provided by keyfunc.

keyfunc may be any callable that takes an object and returns an object for use as a dictionary key.

The keyfunc will be called every time the ORM needs to add a member by value-only (such as when loading instances from the database) or remove a member. The usual cautions about dictionary keying apply- keyfunc(object) should return the same output for the life of the collection. Keying based on mutable properties can result in unreachable instances "lost" in the collection.

@collection.remover
@collection.internally_instrumented
def remove(self, value, _sa_initiator=None):
Remove an item by value, consulting the keyfunc for the key.
@collection.appender
@collection.internally_instrumented
def set(self, value, _sa_initiator=None):
Add an item by value, consulting the keyfunc for the key.
keyfunc =

Undocumented