DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
conffwk.dalproperty Namespace Reference

Functions

 _return_relation (relation, multi=False, data=None, dalobj=None, cache=None)
 _assign_relation (relation)
 _return_attribute (attribute, dalobj=None, value=None)
 _assign_attribute (attribute)

Function Documentation

◆ _assign_attribute()

_assign_attribute ( attribute)
protected

Definition at line 66 of file dalproperty.py.

66def _assign_attribute(attribute):
67 from .dal import DalBase
68
69 def setter(obj, value):
70 setattr(obj, '__%s' % attribute, value)
71 getattr(DalBase, '_updated').add(obj)
72
73 return setter

◆ _assign_relation()

_assign_relation ( relation)
protected

Definition at line 45 of file dalproperty.py.

45def _assign_relation(relation):
46 from .dal import DalBase
47
48 def setter(obj, value):
49 setattr(obj, '__%s' % relation, value)
50 getattr(DalBase, '_updated').add(obj)
51
52 return setter
53
54

◆ _return_attribute()

_return_attribute ( attribute,
dalobj = None,
value = None )
protected

Definition at line 55 of file dalproperty.py.

55def _return_attribute(attribute, dalobj=None, value=None):
56
57 if dalobj:
58 setattr(dalobj, '__%s' % attribute, value)
59
60 def getter(obj):
61 return getattr(obj, '__%s' % attribute)
62
63 return getter
64
65

◆ _return_relation()

_return_relation ( relation,
multi = False,
data = None,
dalobj = None,
cache = None )
protected

Definition at line 9 of file dalproperty.py.

10 dalobj=None, cache=None):
11
12 if dalobj:
13 setattr(dalobj, '__%s_data' % relation, (data, cache))
14
15 def getter(obj):
16
17 try:
18 val = getattr(obj, '__%s' % relation)
19 except AttributeError:
20 try:
21 ldata, lcache = obj.__dict__.pop('__%s_data' % relation)
22 except KeyError:
23 raise AttributeError
24
25 if not multi:
26 ldata = [ldata]
27
28 val = []
29 for k in ldata:
30 if k.UID() in lcache[k.class_name()]:
31 val.append(lcache[k.class_name()][k.UID()])
32 else:
33 val.append(k.as_dal(lcache))
34
35 if not multi:
36 val = val[0]
37
38 setattr(obj, '__%s' % relation, val)
39
40 return val
41
42 return getter
43
44