25 **kw):
26
27 """Helper for setting up an association via an index.
28
29 parent: The parent D3PDobject or block.
30 assoctool: The class for the (single) association tool.
31 target: The label for the getter within which we look up the index.
32 prefix: Prefix to add to the contained variables, if any.
33 level: Level of detail for the block.
34 blockname: Name for the block.
35 allowMissing: If true, then it is not considered an error for the
36 target getter to fail to find the input objects.
37
38 Extra arguments are passed to the association tool.
39"""
40
41 if blockname is None:
42 blockname = assoctool.__name__
43
44 def maker (name, prefix, object_name, **kw2):
45 this_target = target
46 if 'target' in kw2:
47 this_target = kw2['target']
48 del kw2['target']
49
50 if this_target == '':
51 this_target = []
52 elif not isinstance(this_target, list):
53 this_target = [ this_target ]
54
55 assoc = assoctool (name + 'Assoc', **kw2)
57 (name, Prefix = prefix, Associator = assoc, Matched = '')
59 (name + 'Index',
60 Targets = this_target,
61 ContainerIndexName = containerIndexName,
62 AllowMissing = allowMissing)
63 filler.BlockFillers += [indexer]
64 filler += [indexer]
65 return filler
66
67 obj = D3PDObject (maker, prefix)
68 parent.defineBlock (level, blockname, obj, **kw)
69 return obj