]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Reinstate elementtree example
authorVraj Mohan <radhakrishnan.vrajmohan@gsa.gov>
Sun, 13 Jan 2019 19:16:55 +0000 (11:16 -0800)
committerVraj Mohan <radhakrishnan.vrajmohan@gsa.gov>
Sun, 13 Jan 2019 19:16:55 +0000 (11:16 -0800)
Partially fixes sqlalchemy/sqlalchemy#4426

examples/elementtree/__init__.py
examples/elementtree/adjacency_list.py
examples/elementtree/pickle_type.py [moved from examples/elementtree/pickle.py with 93% similarity]

index 82d00ff5ad7d393de4fd51cdca3f9afd6f5274be..82bb873610f607f3add3824a10d2622f2c8eac1a 100644 (file)
@@ -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
 
 """
index 6dd88c7973d603b625bd6c3bb15b734701151805..51c0b32d6702de33c39db4920feff3a9c5032670 100644 (file)
@@ -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.
 
 """
similarity index 93%
rename from examples/elementtree/pickle.py
rename to examples/elementtree/pickle_type.py
index ca2c6550494ea305a82fa5701e9f3f0a83d287d5..fee5286598bbf032b2e106a9a05d5ae6e102fd2b 100644 (file)
@@ -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)