MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / persistent_id

Method persistent_id

lib/sqlalchemy/ext/serializer.py:90–116  ·  view source on GitHub ↗
(self, obj)

Source from the content-addressed store, hash-verified

88class Serializer(pickle.Pickler):
89
90 def persistent_id(self, obj):
91 # print "serializing:", repr(obj)
92 if isinstance(obj, Mapper):
93 id_ = "mapper:" + b64encode(pickle.dumps(obj.class_))
94 elif isinstance(obj, MapperProperty):
95 id_ = (
96 "mapperprop:"
97 + b64encode(pickle.dumps(obj.parent.class_))
98 + ":"
99 + obj.key
100 )
101 elif isinstance(obj, Table):
102 if "parententity" in obj._annotations:
103 id_ = "mapper_selectable:" + b64encode(
104 pickle.dumps(obj._annotations["parententity"].class_)
105 )
106 else:
107 id_ = f"table:{obj.key}"
108 elif isinstance(obj, Column) and isinstance(obj.table, Table):
109 id_ = f"column:{obj.table.key}:{obj.key}"
110 elif isinstance(obj, Session):
111 id_ = "session:"
112 elif isinstance(obj, Engine):
113 id_ = "engine:"
114 else:
115 return None
116 return id_
117
118
119our_ids = re.compile(

Callers

nothing calls this directly

Calls 2

b64encodeFunction · 0.85
dumpsMethod · 0.45

Tested by

no test coverage detected