Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary set a warning if the layer is not found instead of info, log the project in instance versus MAP #57

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions lizmap_server/legend_onoff_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ def __init__(self, server_interface: QgsServerInterface):
self.style_map = None
self.renderers_config = None

def _setup_legend(self, qs, onoff):
def _setup_legend(self, qs: str, onoff: bool, project: QgsProject):

if not qs or ':' not in qs:
return

logger = Logger()
# noinspection PyArgumentList
project: QgsProject = QgsProject.instance()

for legend_layer in qs.split(';'):
layer_name, key_list = legend_layer.split(':')
Expand All @@ -45,7 +43,9 @@ def _setup_legend(self, qs, onoff):

layer = find_vector_layer(layer_name, project)
if not layer:
logger.info("Skipping the layer '{}' because it's not a vector layer".format(layer_name))
logger.warning(
"LegendOnOFF::RequestReady : Skipping the layer '{}' because it's not a vector layer".format(
layer_name))
continue

try:
Expand Down Expand Up @@ -105,10 +105,19 @@ def requestReady(self):
except Exception:
self.style_map = {}

# noinspection PyArgumentList
project: QgsProject = QgsProject.instance()
logger.warning(
'LegendOnOFF::requestReady : project instance : {} \n against MAP = {}'.format(
project.fileName(),
params.get('MAP', ''),
)
)

if 'LEGEND_ON' in params:
self._setup_legend(params['LEGEND_ON'], True)
self._setup_legend(params['LEGEND_ON'], True, project)
if 'LEGEND_OFF' in params:
self._setup_legend(params['LEGEND_OFF'], False)
self._setup_legend(params['LEGEND_OFF'], False, project)

@exception_handler
def responseComplete(self):
Expand All @@ -124,14 +133,23 @@ def responseComplete(self):
if len(self.renderers_config) == 0:
return

params = handler.parameterMap()

# noinspection PyArgumentList
project: QgsProject = QgsProject.instance()
logger.warning(
'LegendOnOFF::responseComplete : project instance : {} \n against MAP = {}'.format(
project.fileName(),
params.get('MAP', '')
))

for layer_name, renderer_config in self.renderers_config.items():
layer = find_vector_layer(layer_name, project)
if not layer:
logger.info("Skipping the layer '{}' because it's not a vector layer".format(layer_name))
logger.warning(
"ResponseComplete : Skipping the layer '{}' because it's not a vector layer".format(layer_name))
continue

try:
config = self.renderers_config[layer_name]

Expand Down
Loading