Decorate a method as the 'reconstructor' hook. Designates a single method as the "reconstructor", an ``__init__``-like method that will be called by the ORM after the instance has been loaded from the database or otherwise reconstituted. .. tip:: The :func:`_orm.reconstruc
(fn: _Fn)
| 4314 | |
| 4315 | |
| 4316 | def reconstructor(fn: _Fn) -> _Fn: |
| 4317 | """Decorate a method as the 'reconstructor' hook. |
| 4318 | |
| 4319 | Designates a single method as the "reconstructor", an ``__init__``-like |
| 4320 | method that will be called by the ORM after the instance has been |
| 4321 | loaded from the database or otherwise reconstituted. |
| 4322 | |
| 4323 | .. tip:: |
| 4324 | |
| 4325 | The :func:`_orm.reconstructor` decorator makes use of the |
| 4326 | :meth:`_orm.InstanceEvents.load` event hook, which can be |
| 4327 | used directly. |
| 4328 | |
| 4329 | The reconstructor will be invoked with no arguments. Scalar |
| 4330 | (non-collection) database-mapped attributes of the instance will |
| 4331 | be available for use within the function. Eagerly-loaded |
| 4332 | collections are generally not yet available and will usually only |
| 4333 | contain the first element. ORM state changes made to objects at |
| 4334 | this stage will not be recorded for the next flush() operation, so |
| 4335 | the activity within a reconstructor should be conservative. |
| 4336 | |
| 4337 | .. seealso:: |
| 4338 | |
| 4339 | :meth:`.InstanceEvents.load` |
| 4340 | |
| 4341 | """ |
| 4342 | fn.__sa_reconstructor__ = True # type: ignore[attr-defined] |
| 4343 | return fn |
| 4344 | |
| 4345 | |
| 4346 | def validates( |