#NEWLINE# @ classmethod #NEWLINE# def setUpClass( cls ) : #NEWLINE# #INDENT# s3db = current . s3db #NEWLINE# s3db . define_table ( 'test_lhierarchy' , Field ( 'name' ) , Field ( 'category' ) , Field ( 'type' ) , * s3_meta_fields ( ) ) #NEWLINE# s3db . define_table ( 'test_lhierarchy_link' , Field ( 'parent_id' , 'reference test_lhierarchy' ) , Field ( 'child_id' , 'reference test_lhierarchy' ) , * s3_meta_fields ( ) ) #NEWLINE# ( s3db . add_components ( 'test_lhierarchy' , test_lhierarchy = { #NEWLINE# #INDENT# 'name' : 'parent' , #NEWLINE# 'link' : 'test_lhierarchy_link' , #NEWLINE# 'joinby' : 'child_id' , #NEWLINE# 'key' : 'parent_id' , #NEWLINE# #UNINDENT# } ) , ) #NEWLINE# xmlstr = '\n<s3xml>\n    <resource name="test_lhierarchy" uuid="LHIERARCHY1">\n        <data field="name">Type 1</data>\n        <data field="category">Cat 0</data>\n        <data field="type">A</data>\n    </resource>\n    <resource name="test_lhierarchy" uuid="LHIERARCHY1-1">\n        <data field="name">Type 1-1</data>\n        <data field="category">Cat 1</data>\n        <data field="type">C</data>\n        <resource name="test_lhierarchy_link">\n            <reference field="parent_id"\n                       resource="test_lhierarchy" uuid="LHIERARCHY1"/>\n        </resource>\n    </resource>\n    <resource name="test_lhierarchy" uuid="LHIERARCHY1-1-1">\n        <data field="name">Type 1-1-1</data>\n        <data field="category">Cat 2</data>\n        <data field="type">B</data>\n        <resource name="test_lhierarchy_link">\n            <reference field="parent_id"\n                       resource="test_lhierarchy" uuid="LHIERARCHY1-1"/>\n        </resource>\n    </resource>\n    <resource name="test_lhierarchy" uuid="LHIERARCHY1-1-2">\n        <data field="name">Type 1-1-2</data>\n        <data field="category">Cat 2</data>\n        <data field="type">A</data>\n        <resource name="test_lhierarchy_link">\n            <reference field="parent_id"\n                       resource="test_lhierarchy" uuid="LHIERARCHY1-1"/>\n        </resource>\n    </resource>\n    <resource name="test_lhierarchy" uuid="LHIERARCHY1-2">\n        <data field="name">Type 1-2</data>\n        <data field="category">Cat 1</data>\n        <data field="type">B</data>\n        <resource name="test_lhierarchy_link">\n            <reference field="parent_id"\n                       resource="test_lhierarchy" uuid="LHIERARCHY1"/>\n        </resource>\n    </resource>\n    <resource name="test_lhierarchy" uuid="LHIERARCHY1-2-1">\n        <data field="name">Type 1-2-1</data>\n        <data field="category">Cat 2</data>\n        <data field="type">B</data>\n        <resource name="test_lhierarchy_link">\n            <reference field="parent_id"\n                       resource="test_lhierarchy" uuid="LHIERARCHY1-2"/>\n        </resource>\n    </resource>\n    <resource name="test_lhierarchy" uuid="LHIERARCHY1-2-2">\n        <data field="name">Type 1-2-2</data>\n        <data field="category">Cat 2</data>\n        <data field="type">C</data>\n        <resource name="test_lhierarchy_link">\n            <reference field="parent_id"\n                       resource="test_lhierarchy" uuid="LHIERARCHY1-2"/>\n        </resource>\n    </resource>\n    <resource name="test_lhierarchy" uuid="LHIERARCHY2">\n        <data field="name">Type 2</data>\n        <data field="category">Cat 0</data>\n        <data field="type">B</data>\n    </resource>\n    <resource name="test_lhierarchy" uuid="LHIERARCHY2-1">\n        <data field="name">Type 2-1</data>\n        <data field="category">Cat 1</data>\n        <data field="type">A</data>\n        <resource name="test_lhierarchy_link">\n            <reference field="parent_id"\n                       resource="test_lhierarchy" uuid="LHIERARCHY2"/>\n        </resource>\n    </resource>\n    <resource name="test_lhierarchy" uuid="LHIERARCHY2-1-1">\n        <data field="name">Type 2-1-1</data>\n        <data field="category">Cat 2</data>\n        <data field="type">C</data>\n        <resource name="test_lhierarchy_link">\n            <reference field="parent_id"\n                       resource="test_lhierarchy" uuid="LHIERARCHY2-1"/>\n        </resource>\n    </resource>\n    <resource name="test_lhierarchy" uuid="LHIERARCHY2-1-2">\n        <data field="name">Type 2-1-2</data>\n        <data field="category">Cat 2</data>\n        <data field="type">D</data>\n        <resource name="test_lhierarchy_link">\n            <reference field="parent_id"\n                       resource="test_lhierarchy" uuid="LHIERARCHY2-1"/>\n        </resource>\n    </resource>\n</s3xml>\n' #NEWLINE# xmltree = etree . ElementTree ( etree . fromstring ( xmlstr ) ) #NEWLINE# current . auth . override = True #NEWLINE# resource = s3db . resource ( 'test_lhierarchy' ) #NEWLINE# resource . import_xml ( xmltree )