{"repo":"IljaOrlovs/sqlalchemy-fsm","free":true,"listed":false,"github":"https://github.com/IljaOrlovs/sqlalchemy-fsm","clone":"git clone https://github.com/IljaOrlovs/sqlalchemy-fsm.git","description":"SQLAlchemy finite state machine support","language":"Python","stars":19,"topics":["declarative","django-fsm","finite-state-machine","fsm","orm","python","python-library","sqlalchemy","state-machine","state-management"],"license":"MIT","category":"databases-storage","readme_excerpt":"sqlalchemy-fsm Declarative finite state machine for SQLAlchemy models. Add an FSMField column, decorate methods with @transition , and let the library enforce which transitions are reachable from which states. Requirements Python 3.10+, SQLAlchemy 2.0+. Install Quickstart source accepts a single state, a list of states, \" \" (any state), or None (matches a nullable column's NULL). Transition API For a transition decorated as BlogPost.publish : Expression Returns --- --- BlogPost.publish() SQLAlchemy filter for rows in the transition's target state — use in .filter(...) . BlogPost.publish.is (True) Same as BlogPost.publish() == True . post.publish.is current bool — is the row in the target state? post.publish.set( args, kwargs) Execute the transition. Raises InvalidSourceStateError if the current state isn't allowed, or PreconditionError if a condition returns falsy. post.publish.can proceed( args, kwargs) bool — would set() succeed right now? set() mutates the field in memory; commit the session yourself. Top-level @transition requires an explicit target= . Sub-handlers inside a class-grouped transition inherit it from the enclosing class. Conditions conditions= gates the transition. Each callable receives the instance plus any args / kwargs forwarded from set() / can proceed() and must return truthy. All must pass. Keep conditions side-effect-free — can proceed() runs them too. Declared states & startup validation FSMField[\"a\", \"b\", \"c\"] declares the closed set of legal state","default_branch":null,"files":null,"tree":[],"storefront":"/r/IljaOrlovs","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/IljaOrlovs/sqlalchemy-fsm/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}