Module Expr Str ImportFrom alias alias alias alias alias alias alias ImportFrom alias alias alias ImportFrom alias alias alias ImportFrom alias ImportFrom alias ClassDef bases NameLoad body FunctionDef arguments args NameParam NameParam NameParam defaults body Return AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Assign SubscriptStore AttributeLoad NameLoad attr Index Str Dict decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Assign SubscriptStore SubscriptLoad AttributeLoad NameLoad attr Index Str Index Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body FunctionDef arguments args NameParam defaults body Return SubscriptLoad SubscriptLoad AttributeLoad NameLoad attr Index Str Index Str decorator_list Return NameLoad decorator_list decorator_list ClassDef bases NameLoad body Assign NameStore NameLoad FunctionDef arguments args NameParam defaults kwarg body For NameStore NameLoad body Expr Call NameLoad NameLoad NameLoad SubscriptLoad NameLoad Index NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body If Call NameLoad NameLoad NameLoad body Return Call NameLoad NameLoad NameLoad orelse TryExcept body Return SubscriptLoad AttributeLoad NameLoad attr Index NameLoad handlers ExceptHandler type NameLoad body Raise Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body If Call NameLoad NameLoad NameLoad body Expr Call NameLoad NameLoad NameLoad NameLoad orelse Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body If Call NameLoad NameLoad NameLoad body Expr Call NameLoad NameLoad NameLoad orelse Delete SubscriptDel AttributeLoad NameLoad attr Index NameLoad decorator_list decorator_list If CompareEq NameLoad Str body Assign NameStore Call NameLoad Str Assign NameStore Call NameLoad Assign NameStore Call NameLoad Str NameLoad Call NameLoad Str NameLoad keyword NameLoad Call NameLoad Str NameLoad Assign NameStore Call NameLoad Str NameLoad Call NameLoad Str NameLoad keyword NameLoad Call NameLoad Str NameLoad Call NameLoad Str NameLoad Call NameLoad Str Expr Call AttributeLoad NameLoad attr NameLoad ClassDef bases NameLoad body Pass decorator_list ClassDef bases NameLoad body Pass decorator_list Expr Call NameLoad NameLoad NameLoad keyword Dict Str Call NameLoad NameLoad Expr Call NameLoad NameLoad NameLoad Assign NameStore Call NameLoad keyword Str keyword ListLoad Call NameLoad keyword Str Call NameLoad keyword Str Assert CompareEq AttributeLoad NameLoad attr Str Assert CompareEq AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index Num attr Str Assign NameStore Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr AttributeLoad NameLoad attr Assert CompareEq AttributeLoad NameLoad attr Str Assert CompareEq AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index Num attr Str Expr Call AttributeLoad AttributeLoad NameLoad attr attr SubscriptLoad AttributeLoad NameLoad attr Index Num Expr Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr AttributeLoad NameLoad attr Assert CompareEq Call NameLoad AttributeLoad NameLoad attr Num
N/A N/A Illustrates customized class instrumentation, using
the :mod:`sqlalchemy.ext.instrumentation` extension package.

In this example, mapped classes are modified to
store their state in a dictionary attached to an attribute
named "_goofy_dict", instead of using __dict__.
this example illustrates how to replace SQLAlchemy's class
descriptors with a user-defined system.


 sqlalchemy create_engine MetaData Table Column Integer Text ForeignKey sqlalchemy.orm mapper relationship Session sqlalchemy.orm.attributes set_attribute get_attribute del_attribute sqlalchemy.orm.instrumentation is_instrumented sqlalchemy.ext.instrumentation InstrumentationManager MyClassState N/A InstrumentationManager N/A get_instance_dict N/A N/A self class_ instance N/A N/A N/A N/A instance _goofy_dict N/A initialize_instance_dict N/A N/A self class_ instance N/A N/A N/A N/A N/A instance __dict__ N/A _goofy_dict N/A N/A install_state N/A N/A self class_ instance state N/A N/A N/A N/A N/A N/A instance __dict__ N/A _goofy_dict N/A state state N/A state_getter N/A N/A self class_ N/A N/A find N/A N/A instance N/A N/A N/A N/A N/A N/A instance __dict__ N/A _goofy_dict N/A state N/A N/A find N/A N/A MyClass N/A object N/A N/A __sa_instrumentation_manager__ MyClassState __init__ N/A N/A self N/A kwargs N/A N/A k kwargs N/A N/A N/A setattr self k N/A kwargs N/A k N/A __getattr__ N/A N/A self key N/A N/A N/A N/A is_instrumented self key N/A N/A N/A get_attribute self key N/A N/A N/A N/A N/A N/A self _goofy_dict N/A key N/A N/A N/A KeyError N/A N/A N/A AttributeError key N/A __setattr__ N/A N/A self key value N/A N/A N/A N/A is_instrumented self key N/A N/A N/A set_attribute self key value N/A N/A N/A N/A self _goofy_dict N/A key value N/A __delattr__ N/A N/A self key N/A N/A N/A N/A is_instrumented self key N/A N/A N/A del_attribute self key N/A N/A N/A N/A self _goofy_dict N/A key N/A N/A N/A N/A __name__ __main__ N/A N/A engine N/A create_engine sqlite:// N/A meta N/A MetaData N/A table1 N/A Table table1 meta N/A Column id Integer primary_key True N/A Column name Text N/A table2 N/A Table table2 meta N/A Column id Integer primary_key True N/A Column name Text N/A Column t1id Integer N/A ForeignKey table1.id N/A N/A N/A meta create_all engine A N/A MyClass N/A N/A N/A B N/A MyClass N/A N/A N/A N/A N/A mapper A table1 properties N/A bs N/A relationship B N/A N/A mapper B table2 N/A a1 N/A A name a1 bs N/A N/A B name b1 N/A B name b2 N/A N/A N/A a1 name a1 N/A N/A N/A N/A N/A a1 bs N/A 0 name b1 N/A sess N/A Session engine N/A N/A N/A sess add a1 N/A N/A N/A sess commit N/A a1 N/A N/A N/A N/A sess query A get N/A a1 id N/A N/A N/A a1 name a1 N/A N/A N/A N/A N/A a1 bs N/A 0 name b1 N/A N/A N/A N/A a1 bs remove N/A N/A a1 bs N/A 0 N/A N/A N/A sess commit N/A a1 N/A N/A N/A N/A sess query A get N/A a1 id N/A N/A N/A len N/A a1 bs 1