summaryrefslogtreecommitdiff
path: root/examples/custom_attributes
diff options
context:
space:
mode:
authorMichael Trier <mtrier@gmail.com>2009-03-31 22:31:08 +0000
committerMichael Trier <mtrier@gmail.com>2009-03-31 22:31:08 +0000
commit6010afb28f95c7050ca48ddd2e6f65ca6cbae5a1 (patch)
tree46259c03c209a89702c32c939c8ea035edee9425 /examples/custom_attributes
parent832ea82fefa366f4717e889511f66ecfce3313de (diff)
downloadsqlalchemy-6010afb28f95c7050ca48ddd2e6f65ca6cbae5a1.tar.gz
Lots of fixes to the code examples to specify imports explicitly.
Explicit imports make it easier for users to understand the examples. Additionally a lot of the examples were fixed to work with the changes in the 0.5.x code base. One small correction to the Case expression. Thanks a bunch to Adam Lowry! Fixes #717.
Diffstat (limited to 'examples/custom_attributes')
-rw-r--r--examples/custom_attributes/custom_management.py12
-rw-r--r--examples/custom_attributes/listen_for_events.py6
2 files changed, 10 insertions, 8 deletions
diff --git a/examples/custom_attributes/custom_management.py b/examples/custom_attributes/custom_management.py
index 707e182ba..b8ea70dfd 100644
--- a/examples/custom_attributes/custom_management.py
+++ b/examples/custom_attributes/custom_management.py
@@ -9,8 +9,10 @@ of "instance.__dict__". Note that the default collection implementations can be
with a custom attribute system as well.
"""
-from sqlalchemy import *
-from sqlalchemy.orm import *
+from sqlalchemy import (create_engine, MetaData, Table, Column, Integer, Text,
+ ForeignKey)
+from sqlalchemy.orm import (mapper, relation, create_session,
+ InstrumentationManager)
from sqlalchemy.orm.attributes import set_attribute, get_attribute, del_attribute, is_instrumented
from sqlalchemy.orm.collections import collection_adapter
@@ -170,10 +172,10 @@ if __name__ == '__main__':
assert isinstance(a1.bs, MyCollection)
sess = create_session()
- sess.save(a1)
+ sess.add(a1)
sess.flush()
- sess.clear()
+ sess.expunge_all()
a1 = sess.query(A).get(a1.id)
@@ -184,7 +186,7 @@ if __name__ == '__main__':
a1.bs.remove(a1.bs[0])
sess.flush()
- sess.clear()
+ sess.expunge_all()
a1 = sess.query(A).get(a1.id)
assert len(a1.bs) == 1
diff --git a/examples/custom_attributes/listen_for_events.py b/examples/custom_attributes/listen_for_events.py
index de28df5b3..3264b0246 100644
--- a/examples/custom_attributes/listen_for_events.py
+++ b/examples/custom_attributes/listen_for_events.py
@@ -39,8 +39,8 @@ class AttributeListener(AttributeExtension):
if __name__ == '__main__':
- from sqlalchemy import *
- from sqlalchemy.orm import *
+ from sqlalchemy import Column, Integer, String, ForeignKey
+ from sqlalchemy.orm import relation
from sqlalchemy.ext.declarative import declarative_base
class Base(object):
@@ -82,4 +82,4 @@ if __name__ == '__main__':
m1.related.mapped.append(MyMappedClass(data='m2'))
del m1.data
- \ No newline at end of file
+