diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-10-23 17:09:53 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-10-23 17:09:53 -0400 |
| commit | 6f4f497f00d55008e4ee612f43b91c3767e0eebe (patch) | |
| tree | c5ce67fe143bb87a476b81a64286e6012382619d /lib/sqlalchemy/orm | |
| parent | 79c25ede440e80e15c4c789234157d0e9497349c (diff) | |
| download | sqlalchemy-6f4f497f00d55008e4ee612f43b91c3767e0eebe.tar.gz | |
- make a futile attempt to combat the needless usage of clear_mappers() in the wild,
[ticket:1861]
Diffstat (limited to 'lib/sqlalchemy/orm')
| -rw-r--r-- | lib/sqlalchemy/orm/__init__.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/sqlalchemy/orm/__init__.py b/lib/sqlalchemy/orm/__init__.py index d4e436b3b..18031e15f 100644 --- a/lib/sqlalchemy/orm/__init__.py +++ b/lib/sqlalchemy/orm/__init__.py @@ -963,11 +963,24 @@ def compile_mappers(): m.compile() def clear_mappers(): - """Remove all mappers that have been created thus far. - - The mapped classes will return to their initial "unmapped" state and can - be re-mapped with new mappers. - + """Remove all mappers from all classes. + + This function removes all instrumentation from classes and disposes + of their associated mappers. Once called, the classes are unmapped + and can be later re-mapped with new mappers. + + :func:`.clear_mappers` is *not* for normal use, as there is literally no + valid usage for it outside of very specific testing scenarios. Normally, + mappers are permanent structural components of user-defined classes, and + are never discarded independently of their class. If a mapped class itself + is garbage collected, its mapper is automatically disposed of as well. As + such, :func:`.clear_mappers` is only for usage in test suites that re-use + the same classes with different mappings, which is itself an extremely rare + use case - the only such use case is in fact SQLAlchemy's own test suite, + and possibly the test suites of other ORM extension libraries which + intend to test various combinations of mapper construction upon a fixed + set of classes. + """ mapperlib._COMPILE_MUTEX.acquire() try: |
