summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-04-28 16:19:43 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2022-05-03 15:58:45 -0400
commit1fa3e2e3814b4d28deca7426bb3f36e7fb515496 (patch)
tree9b07b8437b1190227c2e8c51f2e942936721000f /examples
parent6a496a5f40efe6d58b09eeca9320829789ceaa54 (diff)
downloadsqlalchemy-1fa3e2e3814b4d28deca7426bb3f36e7fb515496.tar.gz
pep484: attributes and related
also implements __slots__ for QueryableAttribute, InstrumentedAttribute, Relationship.Comparator. Change-Id: I47e823160706fc35a616f1179a06c7864089e5b5
Diffstat (limited to 'examples')
-rw-r--r--examples/custom_attributes/custom_management.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/examples/custom_attributes/custom_management.py b/examples/custom_attributes/custom_management.py
index 5ee5a45f8..aa9ea7a68 100644
--- a/examples/custom_attributes/custom_management.py
+++ b/examples/custom_attributes/custom_management.py
@@ -17,7 +17,7 @@ from sqlalchemy import MetaData
from sqlalchemy import Table
from sqlalchemy import Text
from sqlalchemy.ext.instrumentation import InstrumentationManager
-from sqlalchemy.orm import mapper
+from sqlalchemy.orm import registry as _reg
from sqlalchemy.orm import relationship
from sqlalchemy.orm import Session
from sqlalchemy.orm.attributes import del_attribute
@@ -26,6 +26,9 @@ from sqlalchemy.orm.attributes import set_attribute
from sqlalchemy.orm.instrumentation import is_instrumented
+registry = _reg()
+
+
class MyClassState(InstrumentationManager):
def get_instance_dict(self, class_, instance):
return instance._goofy_dict
@@ -97,9 +100,9 @@ if __name__ == "__main__":
class B(MyClass):
pass
- mapper(A, table1, properties={"bs": relationship(B)})
+ registry.map_imperatively(A, table1, properties={"bs": relationship(B)})
- mapper(B, table2)
+ registry.map_imperatively(B, table2)
a1 = A(name="a1", bs=[B(name="b1"), B(name="b2")])