add an object to a layer

def add_object(self, obj):
        '''add an object to a layer'''
        state = self.state
        if not obj.layer in state.layers:
            # its a new layer
            state.layers[obj.layer] = {}
        state.layers[obj.layer][obj.key] = obj
        state.need_redraw = True
        if (not self.legend_checkbox_menuitem_added and
            isinstance(obj, SlipFlightModeLegend)):
            self.add_legend_checkbox_menuitem()
            self.legend_checkbox_menuitem_added = True
            self.SetMenuBar(self.menu.wx_menu())