MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / persistent_load

Method persistent_load

lib/sqlalchemy/ext/serializer.py:141–171  ·  view source on GitHub ↗
(self, id_)

Source from the content-addressed store, hash-verified

139 return None
140
141 def persistent_load(self, id_):
142 m = our_ids.match(str(id_))
143 if not m:
144 return None
145 else:
146 type_, args = m.group(1, 2)
147 if type_ == "attribute":
148 key, clsarg = args.split(":")
149 cls = pickle.loads(b64decode(clsarg))
150 return getattr(cls, key)
151 elif type_ == "mapper":
152 cls = pickle.loads(b64decode(args))
153 return class_mapper(cls)
154 elif type_ == "mapper_selectable":
155 cls = pickle.loads(b64decode(args))
156 return class_mapper(cls).__clause_element__()
157 elif type_ == "mapperprop":
158 mapper, keyname = args.split(":")
159 cls = pickle.loads(b64decode(mapper))
160 return class_mapper(cls).attrs[keyname]
161 elif type_ == "table":
162 return self.metadata.tables[args]
163 elif type_ == "column":
164 table, colname = args.split(":")
165 return self.metadata.tables[table].c[colname]
166 elif type_ == "session":
167 return self.scoped_session()
168 elif type_ == "engine":
169 return self.get_engine()
170 else:
171 raise Exception("Unknown token: %s" % type_)
172
173
174def dumps(obj, protocol=pickle.HIGHEST_PROTOCOL):

Callers

nothing calls this directly

Calls 7

get_engineMethod · 0.95
b64decodeFunction · 0.85
class_mapperFunction · 0.85
splitMethod · 0.80
matchMethod · 0.45
loadsMethod · 0.45
__clause_element__Method · 0.45

Tested by

no test coverage detected