Hi Alex,
O.K. redid my report using the Tk designer and added a few fields and
preview - success:-) .
Now to my question I define my fields like this:
"drinkinfo.subregion_lv.name" and my "data" contains a few entries of
type "cellarbook" each of them has "drinkinfo" relation and it I have
things like "country_lv", "subregion_lv" etc etc, some of them are
optional, i.e. not present on all rows. How should that be defined in
the "expr"?
Could I call a method of my own, something along these lines:
def getRelInfo(objval, sainst):
"""Get related information
:param objval: e.g. "drinkinfo.someoptionalrel.name"
:param sainst: an SA Instance of the row, e.g. a "cellarbook" entry/row
:return: the column value or blank
"""
try:
newAttr = sainst
parts = objval.attribute_name.split(".")
rel, colname = (parts[:-1], parts[-1:][0])
for r in rel:
if newAttr:
with no_autoflush(wx.GetApp().ds):
newAttr = getattr(newAttr, r)
if newAttr:
return getattr(newAttr, colname)
else:
return ""
Thanks for hints, or links to documentation or a examples.
Werner
|