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 @@
# orm/collections.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
@@ -21,6 +21,8 @@ provided. One is a bundle of generic decorators that map function arguments
and return values to events::
from sqlalchemy.orm.collections import collection
class MyClass:
# ...
@@ -32,7 +34,6 @@ and return values to events::
def pop(self):
return self.data.pop()
The second approach is a bundle of targeted decorators that wrap appropriate
append and remove notifiers around the mutation methods present in the
standard Python ``list``, ``set`` and ``dict`` interfaces. These could be
@@ -73,10 +74,11 @@ generally not needed. Odds are, the extension method will delegate to a
method that's already instrumented. For example::
class QueueIsh(list):
def push(self, item):
self.append(item)
def shift(self):
return self.pop(0)
def push(self, item):
self.append(item)
def shift(self):
return self.pop(0)
There's no need to decorate these methods. ``append`` and ``pop`` are already
instrumented as part of the ``list`` interface. Decorating them would fire
@@ -148,10 +150,12 @@ __all__ = [
"keyfunc_mapping",
"column_keyed_dict",
"attribute_keyed_dict",
"column_keyed_dict",
"attribute_keyed_dict",
"MappedCollection",
"KeyFuncDict",
# old names in < 2.0
"mapped_collection",
"column_mapped_collection",
"attribute_mapped_collection",
"MappedCollection",
]
__instrumentation_mutex = threading.Lock()
@@ -193,9 +197,10 @@ class collection:
The recipe decorators all require parens, even those that take no
arguments::
@collection.adds('entity')
@collection.adds("entity")
def insert(self, position, entity): ...
@collection.removes_return()
def popitem(self): ...
@@ -215,11 +220,13 @@ class collection:
@collection.appender
def add(self, append): ...
# or, equivalently
@collection.appender
@collection.adds(1)
def add(self, append): ...
# for mapping type, an 'append' may kick out a previous value
# that occupies that slot. consider d['a'] = 'foo'- any previous
# value in d['a'] is discarded.
@@ -259,10 +266,11 @@ class collection:
@collection.remover
def zap(self, entity): ...
# or, equivalently
@collection.remover
@collection.removes_return()
def zap(self, ): ...
def zap(self): ...
If the value to remove is not present in the collection, you may
raise an exception or return None to ignore the error.
@@ -362,7 +370,8 @@ class collection:
@collection.adds(1)
def push(self, item): ...
@collection.adds('entity')
@collection.adds("entity")
def do_stuff(self, thing, entity=None): ...
"""