dorm.contrib.asyncmodel¶
AsyncModel — Model variant that rejects sync ORM calls.
API¶
dorm.contrib.asyncmodel.AsyncModel
¶
Bases: Model
Subclass this instead of :class:dorm.Model to forbid sync
ORM access on the resulting class.
The async-only contract is enforced two ways:
- The default
objectsmanager is replaced with an :class:AsyncOnlyManager— any sync class-level call (e.g.MyModel.objects.create(...)) raises :class:AsyncOnlyError. - Instance-level :meth:
saveand :meth:deleteraise the same error — callers must use :meth:asaveand :meth:adelete.
Sub-classing rules: AsyncModel itself stays abstract (no
table). Concrete subclasses get the strict-async behaviour
automatically; you can still override objects if you want a
custom async-only Manager subclass.
dorm.contrib.asyncmodel.AsyncOnlyManager
¶
Bases: Manager
Manager that forwards async methods and rejects sync ones.
Async methods (aall, afilter, acreate, aget,
etc.) hit the parent implementation untouched. Every sync method
raises :class:AsyncOnlyError.
dorm.contrib.asyncmodel.AsyncOnlyError
¶
Bases: RuntimeError
Raised when sync ORM API is called on an :class:AsyncModel.
Carries the offending method name for clearer test assertions and
log messages. Subclasses :class:RuntimeError so generic
error handlers degrade gracefully.