1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
request.tm.begin()

uris = m.get_all_uris(request.dbsession)

for uri in uris:
    if uri.node and uri.node.children.count() <= 0:
        print("deleted node: {}".format(uri.node.id))
        request.dbsession.delete(uri.node)
        request.dbsession.delete(uri)

request.dbsession.flush()

request.tm.commit()