Debian Codegraph @

doc/walker

raw
1 Walker methods
2 --------------
3
4 In the COPY, DELETE and MOVE methods we need to walk over
5 a tree of resources and collections in order to copy, delete
6 or move them.
7
8 The difference between all these walks is only that we perform
9 a different action on the resources we visit. Thus it might be
10 the simplest solution to provide a walker class or method to
11 do that work and give it a function to perform before starting.
12
13
14 Way of walking
15 --------------
16
17 When we delete things we should do it bottom up but when we copy
18 or move things we should create resources top down. Thus we actually
19 need 2 methods.
20
21 But the following method might work: We create a list of all the nodes
22 in the tree in tree order (means top down, left to right). When
23 we walk over this list from begin to end we can copy and when we
24 move backwards we can delete.
25
26 Thus we need an indicator for the direction and the method to
27 perform on it.
28
29
30 Here the iterative approach (in order to save memory):
31 dc = dataclass
32 queue = list = [start_uri]
33 while len(queue):
34 element = queue[-1]
35 childs = dc.get_childs(element)
36 if childs:
37 list = list + childs
38 # update queue
39 del queue[-1]
40 if childs:
41 queue = queue + childs
42
43
44 (first try..)
45
46
47
48
49
50