print document
.. autosource::
- :files: pickle.py, adjacency_list.py, optimized_al.py
+ :files: pickle_type.py, adjacency_list.py, optimized_al.py
"""
(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.
"""
from sqlalchemy import Table
from sqlalchemy.orm import mapper
from sqlalchemy.orm import Session
+from sqlalchemy.util import py3k
e = create_engine("sqlite://")
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)