MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _set_collection_attributes

Function _set_collection_attributes

lib/sqlalchemy/orm/collections.py:944–963  ·  view source on GitHub ↗

apply ad-hoc instrumentation from decorators, class-level defaults and implicit role declarations

(cls, roles, methods)

Source from the content-addressed store, hash-verified

942
943
944def _set_collection_attributes(cls, roles, methods):
945 """apply ad-hoc instrumentation from decorators, class-level defaults
946 and implicit role declarations
947
948 """
949 for method_name, (before, argument, after) in methods.items():
950 setattr(
951 cls,
952 method_name,
953 _instrument_membership_mutator(
954 getattr(cls, method_name), before, argument, after
955 ),
956 )
957 # intern the role map
958 for role, method_name in roles.items():
959 setattr(cls, "_sa_%s" % role, getattr(cls, method_name))
960
961 cls._sa_adapter = None
962
963 cls._sa_instrumented = id(cls)
964
965
966def _instrument_membership_mutator(method, before, argument, after):

Callers 1

_instrument_classFunction · 0.85

Calls 2

itemsMethod · 0.45

Tested by

no test coverage detected