From b4d3e6f9ae4bed061ecab88f148e7d150f8fa279 Mon Sep 17 00:00:00 2001 From: Vraj Mohan Date: Sun, 13 Jan 2019 11:16:55 -0800 Subject: [PATCH] Reinstate elementtree example Partially fixes sqlalchemy/sqlalchemy#4426 --- examples/elementtree/__init__.py | 2 +- examples/elementtree/adjacency_list.py | 4 ++-- examples/elementtree/{pickle.py => pickle_type.py} | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) rename examples/elementtree/{pickle.py => pickle_type.py} (93%) diff --git a/examples/elementtree/__init__.py b/examples/elementtree/__init__.py index 82d00ff5ad..82bb873610 100644 --- a/examples/elementtree/__init__.py +++ b/examples/elementtree/__init__.py @@ -20,6 +20,6 @@ E.g.:: print document .. autosource:: - :files: pickle.py, adjacency_list.py, optimized_al.py + :files: pickle_type.py, adjacency_list.py, optimized_al.py """ diff --git a/examples/elementtree/adjacency_list.py b/examples/elementtree/adjacency_list.py index 6dd88c7973..51c0b32d67 100644 --- a/examples/elementtree/adjacency_list.py +++ b/examples/elementtree/adjacency_list.py @@ -10,8 +10,8 @@ along any path with a given structure of attributes, basically a (very narrow) subset of xpath. This example explicitly marshals/unmarshals the ElementTree document into -mapped entities which have their own tables. Compare to pickle.py which uses -pickle to accomplish the same task. Note that the usage of both styles of +mapped entities which have their own tables. Compare to pickle_type.py which uses +PickleType to accomplish the same task. Note that the usage of both styles of persistence are identical, as is the structure of the main Document class. """ diff --git a/examples/elementtree/pickle.py b/examples/elementtree/pickle_type.py similarity index 93% rename from examples/elementtree/pickle.py rename to examples/elementtree/pickle_type.py index ca2c655049..fee5286598 100644 --- a/examples/elementtree/pickle.py +++ b/examples/elementtree/pickle_type.py @@ -23,6 +23,7 @@ from sqlalchemy import String from sqlalchemy import Table from sqlalchemy.orm import mapper from sqlalchemy.orm import Session +from sqlalchemy.util import py3k e = create_engine("sqlite://") @@ -76,4 +77,7 @@ session.commit() document = session.query(Document).filter_by(filename="test.xml").first() # print -document.element.write(sys.stdout) +if py3k: + document.element.write(sys.stdout, encoding="unicode") +else: + document.element.write(sys.stdout) -- 2.47.3