From b5ad47271e68a30b2acd8f990af331de8e1069f3 Mon Sep 17 00:00:00 2001 From: Michael Trier Date: Mon, 13 Apr 2009 03:23:19 +0000 Subject: [PATCH] Cleaned up the deprecation problems with the examples. --- examples/adjacencytree/basic_tree.py | 4 ++-- examples/elementtree/adjacency_list.py | 2 +- examples/elementtree/optimized_al.py | 2 +- examples/elementtree/pickle.py | 2 +- examples/sharding/attribute_shard.py | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/adjacencytree/basic_tree.py b/examples/adjacencytree/basic_tree.py index ac149d68a9..dec03e5504 100644 --- a/examples/adjacencytree/basic_tree.py +++ b/examples/adjacencytree/basic_tree.py @@ -72,7 +72,7 @@ print "Flushing:" print "----------------------------" session = create_session() -session.save(node) +session.add(node) session.flush() print "\n\n\n----------------------------" @@ -113,7 +113,7 @@ print "Clearing session, selecting " print "tree new where node_id=%d:" % nodeid print "----------------------------" -session.clear() +session.expunge_all() t = session.query(TreeNode).filter(TreeNode.id==nodeid)[0] print "\n\n\n----------------------------" diff --git a/examples/elementtree/adjacency_list.py b/examples/elementtree/adjacency_list.py index 9efacad872..58156dcb67 100644 --- a/examples/elementtree/adjacency_list.py +++ b/examples/elementtree/adjacency_list.py @@ -155,7 +155,7 @@ session = create_session() # get ElementTree documents for file in ('test.xml', 'test2.xml', 'test3.xml'): - filename = os.path.join(os.path.dirname(sys.argv[0]), file) + filename = os.path.join(os.path.dirname(__file__), file) doc = ElementTree.parse(filename) session.add(Document(file, doc)) diff --git a/examples/elementtree/optimized_al.py b/examples/elementtree/optimized_al.py index 39d35921a7..c03acee1d4 100644 --- a/examples/elementtree/optimized_al.py +++ b/examples/elementtree/optimized_al.py @@ -164,7 +164,7 @@ session = create_session() # get ElementTree documents for file in ('test.xml', 'test2.xml', 'test3.xml'): - filename = os.path.join(os.path.dirname(sys.argv[0]), file) + filename = os.path.join(os.path.dirname(__file__), file) doc = ElementTree.parse(filename) session.add(Document(file, doc)) diff --git a/examples/elementtree/pickle.py b/examples/elementtree/pickle.py index 53d2ee2b6c..220bb22953 100644 --- a/examples/elementtree/pickle.py +++ b/examples/elementtree/pickle.py @@ -49,7 +49,7 @@ mapper(Document, documents) ###### time to test ! ######### # get ElementTree document -filename = os.path.join(os.path.dirname(sys.argv[0]), "test.xml") +filename = os.path.join(os.path.dirname(__file__), "test.xml") doc = ElementTree.parse(filename) # save to DB diff --git a/examples/sharding/attribute_shard.py b/examples/sharding/attribute_shard.py index 45a019f135..2f03a5a344 100644 --- a/examples/sharding/attribute_shard.py +++ b/examples/sharding/attribute_shard.py @@ -184,10 +184,10 @@ quito.reports.append(Report(85)) sess = create_session() for c in [tokyo, newyork, toronto, london, dublin, brasilia, quito]: - sess.save(c) + sess.add(c) sess.flush() -sess.clear() +sess.expunge_all() t = sess.query(WeatherLocation).get(tokyo.id) assert t.city == tokyo.city -- 2.47.2