def render(self, r):
        """
            Render the tabs row

            @param r: the S3Request
        """

        rheader_tabs = []

        tabs = tuple(t for t in self.tabs if t.active(r))

        mtab = False
        if r.component is None:
            # Check whether there is a tab for the current URL method
            for t in tabs:
                if t.component == r.method:
                    mtab = True
                    break

        record_id = r.id
        if not record_id and r.record:
            record_id = r.record[r.table._id]

        for i, tab in enumerate(tabs):

            # Determine the query variables for the tab URL
            vars_match = tab.vars_match(r)
            if vars_match:
                _vars = Storage(r.get_vars)
            else:
                _vars = Storage(tab.vars)
                if "viewing" in r.get_vars:
                    _vars.viewing = r.get_vars.viewing

            # Determine the controller function for the tab URL
            if tab.function is None:
                # Infer function from current request
                if "viewing" in _vars:
                    tablename, record_id = _vars.viewing.split(".", 1)
                    function = tablename.split("_", 1)[1]
                else:
                    function = r.function
            else:
                # Tab defines controller function
                function = tab.function

            # Is this the current tab?
            component = tab.component
            here = False
            if function == r.name or function == r.function:
                here = r.method == component or not mtab
            if component:
                if r.component and \
                   r.component.alias == component and \
                   vars_match:
                    here = True
                elif not r.component and r.method == component:
                    here = True
                else:
                    here = False
            else:
                if r.component or not vars_match:
                    here = False

            # HTML class for the tab position
            if here:
                _class = "tab_here"
            elif i == len(tabs) - 1:
                _class = "tab_last"
            else:
                _class = "tab_other"

            # Complete the tab URL with args, deal with "viewing"
            if component:
                if record_id:
                    args = [record_id, component]
                else:
                    args = [component]
                if _vars in "viewing":
                    del _vars["viewing"]
                _href = URL(function, args=args, vars=_vars)
                _id = "rheader_tab_%s" % component
            else:
                args = []
                if function != r.name and not tab.native:
                    if "viewing" not in _vars and r.id:
                        _vars.update(viewing="%s.%s" % (r.tablename, r.id))
                    elif not tab.component and not tab.function:
                        if "viewing" in _vars:
                            del _vars["viewing"]
                        args = [record_id]
                else:
                    if "viewing" not in _vars and record_id:
                        args = [record_id]
                _href = URL(function, args=args, vars=_vars)
                _id = "rheader_tab_%s" % function

            # Render tab
            rheader_tabs.append(SPAN(A(tab.title,
                                       _href=_href,
                                       _id=_id,
                                       ),
                                     _class=_class,
                                     ))

        # Render tab row
        if rheader_tabs:
            rheader_tabs = DIV(rheader_tabs, _class="tabs")
        else:
            rheader_tabs = ""
        return rheader_tabs

# =============================================================================
dataset/ETHPy150Open sahana/eden/modules/s3/s3navigation.py/S3ComponentTabs.render/swapped operands of `in`