1
0
mirror of https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git synced 2025-08-14 00:25:46 +02:00

Проверка 09.02.2025

This commit is contained in:
MoonTestUse1
2025-02-09 01:11:49 +06:00
parent ce52f8a23a
commit 0aa3ef8fc2
5827 changed files with 14316 additions and 1906434 deletions

View File

@@ -1,5 +1,5 @@
# event/base.py
# Copyright (C) 2005-2024 the SQLAlchemy authors and contributors
# Copyright (C) 2005-2025 the SQLAlchemy authors and contributors
# <see AUTHORS file>
#
# This module is part of SQLAlchemy and is released under
@@ -191,13 +191,8 @@ class _Dispatch(_DispatchCommon[_ET]):
:class:`._Dispatch` objects.
"""
if "_joined_dispatch_cls" not in self.__class__.__dict__:
cls = type(
"Joined%s" % self.__class__.__name__,
(_JoinedDispatcher,),
{"__slots__": self._event_names},
)
self.__class__._joined_dispatch_cls = cls
assert "_joined_dispatch_cls" in self.__class__.__dict__
return self._joined_dispatch_cls(self, other)
def __reduce__(self) -> Union[str, Tuple[Any, ...]]:
@@ -328,6 +323,51 @@ class _HasEventsDispatch(Generic[_ET]):
else:
dispatch_target_cls.dispatch = dispatcher(cls)
klass = type(
"Joined%s" % dispatch_cls.__name__,
(_JoinedDispatcher,),
{"__slots__": event_names},
)
dispatch_cls._joined_dispatch_cls = klass
# establish pickle capability by adding it to this module
globals()[klass.__name__] = klass
class _JoinedDispatcher(_DispatchCommon[_ET]):
"""Represent a connection between two _Dispatch objects."""
__slots__ = "local", "parent", "_instance_cls"
local: _DispatchCommon[_ET]
parent: _DispatchCommon[_ET]
_instance_cls: Optional[Type[_ET]]
def __init__(
self, local: _DispatchCommon[_ET], parent: _DispatchCommon[_ET]
):
self.local = local
self.parent = parent
self._instance_cls = self.local._instance_cls
def __reduce__(self) -> Any:
return (self.__class__, (self.local, self.parent))
def __getattr__(self, name: str) -> _JoinedListener[_ET]:
# Assign _JoinedListeners as attributes on demand
# to reduce startup time for new dispatch objects.
ls = getattr(self.local, name)
jl = _JoinedListener(self.parent, ls.name, ls)
setattr(self, ls.name, jl)
return jl
def _listen(self, event_key: _EventKey[_ET], **kw: Any) -> None:
return self.parent._listen(event_key, **kw)
@property
def _events(self) -> Type[_HasEventsDispatch[_ET]]:
return self.parent._events
class Events(_HasEventsDispatch[_ET]):
"""Define event listening functions for a particular target type."""
@@ -340,9 +380,11 @@ class Events(_HasEventsDispatch[_ET]):
return all(isinstance(target.dispatch, t) for t in types)
def dispatch_parent_is(t: Type[Any]) -> bool:
return isinstance(
cast("_JoinedDispatcher[_ET]", target.dispatch).parent, t
)
parent = cast("_JoinedDispatcher[_ET]", target.dispatch).parent
while isinstance(parent, _JoinedDispatcher):
parent = cast("_JoinedDispatcher[_ET]", parent).parent
return isinstance(parent, t)
# Mapper, ClassManager, Session override this to
# also accept classes, scoped_sessions, sessionmakers, etc.
@@ -382,38 +424,6 @@ class Events(_HasEventsDispatch[_ET]):
cls.dispatch._clear()
class _JoinedDispatcher(_DispatchCommon[_ET]):
"""Represent a connection between two _Dispatch objects."""
__slots__ = "local", "parent", "_instance_cls"
local: _DispatchCommon[_ET]
parent: _DispatchCommon[_ET]
_instance_cls: Optional[Type[_ET]]
def __init__(
self, local: _DispatchCommon[_ET], parent: _DispatchCommon[_ET]
):
self.local = local
self.parent = parent
self._instance_cls = self.local._instance_cls
def __getattr__(self, name: str) -> _JoinedListener[_ET]:
# Assign _JoinedListeners as attributes on demand
# to reduce startup time for new dispatch objects.
ls = getattr(self.local, name)
jl = _JoinedListener(self.parent, ls.name, ls)
setattr(self, ls.name, jl)
return jl
def _listen(self, event_key: _EventKey[_ET], **kw: Any) -> None:
return self.parent._listen(event_key, **kw)
@property
def _events(self) -> Type[_HasEventsDispatch[_ET]]:
return self.parent._events
class dispatcher(Generic[_ET]):
"""Descriptor used by target classes to
deliver the _Dispatch class at the class level