r🍪
Size: a a a
r🍪
e☮
e☮
e☮

e☮
T
e☮
e☮
T
T
e☮
forms = {
«select1»: {FormField1, FormField2, FormField3},
«select2»: {FormField4}
}e☮
Сс
Сс

h
class FlaskDB(Flask):
def __init__(self,
import_name: str,
static_url_path: Optional[str] = None,
static_folder: Optional[Union[str, os.PathLike]] = "static",
static_host: Optional[str] = None,
host_matching: bool = False,
subdomain_matching: bool = False,
template_folder: Optional[str] = "templates",
instance_path: Optional[str] = None,
instance_relative_config: bool = False,
root_path: Optional[str] = None,
sqlalchemy_engine: Optional[Engine] = None
):
super(FlaskDB, self).__init__(
import_name,
static_url_path=static_url_path,
static_folder=static_folder,
static_host=static_host,
host_matching=host_matching,
subdomain_matching=subdomain_matching,
template_folder=template_folder,
instance_path=instance_path,
instance_relative_config=instance_relative_config,
root_path=root_path
)
self._engine = sqlalchemy_engine
@contextmanager
def session(self) -> ContextManager[Session]:
session = Session(self._engine)
try:
yield session.begin()
except Exception as e:
self.logger.exception(e)
session.rollback()
else:
session.commit()
finally:
session.close()with app.session() as session:
session.execute(...)current_app не видит .sessionT
h
h
T
h