Skip to content

componentType / session["unit"] should be made stateless as possible

Looking at how comments are created (not edited, which is misnamed in the code right now): https://gitlab.cern.ch/YARR/localdb-tools/-/blob/devel-2.2/viewer/pages/component.py?ref_type=heads#L844-867 -- it appears the componentType on the comment is set based on the session variable

        "componentType": session["unit"],

but we have access to the object id via oid here to look up the componentType if we wanted to... but we should just retrieve this on the fly and not store it on the comment itself.

Lots of pieces of this code have lines like

    session["unit"] = "front-end_chip"  ### TODO just temporary coding

and

    if this and "componentType" in this:
        session["unit"] = this["componentType"].lower()  ### TODO wakarinikui
    else:
        session["unit"] = "front-end_chip"

which isn't great as this sets it to front-end_chip which uhhh.. yeah, obviously is misleading sometimes.