3liz/lizmap-plugin

Python error on new project with old files

Antoviscomi opened this issue ยท 35 comments

What is the bug?

  1. copy/past features from an old project to an empty new one
  2. flag to publish from QGIS SERVER properties
  3. open Lizmap plugin to configure your project
`AttributeError: 'NoneType' object has no attribute 'name' 
Traceback (most recent call last):
  File "/home/antonio/.local/share/QGIS/QGIS3/profiles/default/python/plugins/lizmap/plugin.py", line 4447, in run
    self.read_cfg_file()
  File "/home/antonio/.local/share/QGIS/QGIS3/profiles/default/python/plugins/lizmap/plugin.py", line 1827, in read_cfg_file
    data = self.populate_layer_tree()
  File "/home/antonio/.local/share/QGIS/QGIS3/profiles/default/python/plugins/lizmap/plugin.py", line 2216, in populate_layer_tree
    self.process_node(root, None, json_layers)
  File "/home/antonio/.local/share/QGIS/QGIS3/profiles/default/python/plugins/lizmap/plugin.py", line 2179, in process_node
    self.process_node(child, item, json_layers)
  File "/home/antonio/.local/share/QGIS/QGIS3/profiles/default/python/plugins/lizmap/plugin.py", line 2128, in process_node
    self.set_tree_item_data('layer', child_id, json_layers)
  File "/home/antonio/.local/share/QGIS/QGIS3/profiles/default/python/plugins/lizmap/plugin.py", line 2001, in set_tree_item_data
    self.myDic[item_key]['name'] = layer.name()
AttributeError: 'NoneType' object has no attribute 'name''

all the layers are (data are from [(https://github.com/3liz/lizmap-web-client/issues/4026#top)]

files.zip

Furthermore,
from LWC in Repository page, I read this in jelix debug console:

Schermata del 2024-03-15 16-43-49

and the original project I reshared doesn't are visible in repository but they work fine in QGIS desktop

Versions, safeguards, checks summary etc

Versions :

  • Lizmap Web Client : 3.6.10
  • Lizmap plugin : 4.2.7
  • QGIS Desktop : 3.36.0
  • QGIS Server : 3.36.0
  • Py-QGIS-Server : not used
  • QGIS Server plugin DataPlotly : 4.1.0
  • QGIS Server plugin atlasprint : 3.3.2
  • QGIS Server plugin lizmap_server : 2.8.5
  • QGIS Server plugin wfsOutputExtension : 1.8.0
List of safeguards :
  • Mode : normal
  • Allow parent folder : yes
  • Number of parent : 10 folder(s)
  • Prevent other drive : no
  • Prevent PG service : yes
  • Prevent PG Auth DB : yes
  • Force PG user&pass : yes
  • Prevent ECW : no

Check Lizmap plugin

  • I have done the step just before in the Lizmap QGIS desktop plugin before opening this ticket. Otherwise, my ticket is not considered valid and might get closed.

In addition,
When I try to configure by Lizmap Plugin on mine old original project the error message doesn't come out, but the project disappear from repository in LWC (both in 3.6.10 and 3.7.5)

This is very strange ...

I never saw some layers like this :

image

Usually, all layers in QGIS have a an icon the left side, like my green bar on the left.

But you have a lot of layers in red, they don't have an icon and they don't have a proper menu when we right click.

@Gustry I'm just analize the layers/group, deleting one by one, finally when remain only the layer 'land_use' the project works again and the plugin too

Schermata del 2024-03-18 17-53-19

so I think there are something wrong in files of original project (which worked fine until 4.2.7 plugin)

@Antoviscomi I think you need to remove only layers in the "red" section. THey don't have a "right click โ†’ layer properties dialog".

It seems they are broken, I don't think there is a datasource for all in the QGS file.

so I think there are something wrong in files of original project (which worked fine until 4.2.7 plugin)

It's not linked to the plugin @Antoviscomi

QGIS itself is confused with these layers ...

@Gustry that's what I did, but until I removed all layers, left the 'land_use' only, the Python error still appair

@Gustry so I close this topic

This is very strange ...

I never saw some layers like this :

image

Usually, all layers in QGIS have a an icon the left side, like my green bar on the left.

But you have a lot of layers in red, they don't have an icon and they don't have a proper menu when we right click.

All layers are from attached gpkg, I copy/paste them because of the error starts with the original project that I didn't edit, and plently worked with previous (Lizmap plugin/LWC) configurations

@Gustry the problem appear with another of my projects.
I just:

  1. open it;
  2. check it wit 4.2.7 Lizmap plugin version;
  3. automatic solve warnings for project's metadata;
    the result is the disappearition of the project from LWC index with the error in screenshot below

Schermata del 2024-03-20 17-20-40

(note that my original project's name was 'Cetraro2' and not 'CETRARO2' !) Who told to LWC to find a project with total upper case name?

then I'm not be able to see this project in index page as to public my page on LWC anymore

this is the project restored from my backup

Schermata del 2024-03-20 18-26-36

Schermata del 2024-03-20 18-32-13

when I try to edit the configurations with Lizmap Plugin the project disappear after this:

Video.del.20-03-2024.18.36.49.webm

giving back the error in previuos comment

(note that my original project's name was 'Cetraro2' and not 'CETRARO2' !) Who told to LWC to find a project with total upper case name?

Do not worry, this LWC displaying the error message with capital letter. It doesn't impact searching. (I know, not a good choice, I though it was changed)

when I try to edit the configurations with Lizmap Plugin the project disappear after this:

Log in your admin panel, and check your logs, I'm sure you will have something like "invalid CFG file", which might be from #571 which is from QGIS 3.36. Please check the content of the CFG file when it has dispeared

Log in your admin panel, and check your logs, I'm sure you will have something like "invalid CFG file", which might be from #571 which is from QGIS 3.36. Please check the content of the CFG file when it has dispeared

no, @Gustry .cfg it's in correct position (readable and editable by text editor), and this the log
LWC_log..txt
in this log isn't seems to read anythink relate to this issue

@Gustry I think I've indexed the trouble:
in cfg file there was some NaN values instead of 0 (zeroes).
I try to explain:
In QGIS desktop, I filter by name a postgis layer named 'limiti_comunali' (containing Municipality Boudaries), in order to public only the boundary of interest, so in the layer properties the extension become like screenshot below:

Schermata del 2024-03-21 09-57-07

and the Lizmap plugin translate these values of extension as NaN (but zero is not 'Not a Number ;-)' ! ) so in cfg I can read this:

Schermata del 2024-03-21 09-56-15

well, when I manually turn these values to 'zeroes' the project magically reappear in repository and also works as expected in LWC.

Having said this, I can't say if the error is in the Lizmap plugin or in QGIS, let me know how to proceed to avoid this boring workaround while waiting for updates

@Antoviscomi As I said yesterday :

which might be from #571 which is from QGIS 3.36. Please

I keep this ticket open, but it's a different issue with this screenshot :

image

@Antoviscomi As I said yesterday :

which might be from #571 which is from QGIS 3.36. Please

@Gustry yes, of course, but, with zeroes as in QGIS and not 'NaN' (as Lizmap plugin it seems to read from) the issue doesn' exist!

Yes #571, it's Nan values in CFG, due to QGIS 3.36 with layers from PG

@Gustry all the layers in my project are from PG, why only this came out with NaN? And why in QGIS layers properties I read Zeroes instead of NaN?

@Antoviscomi Please check issue #571, it's linked itself to an issue with PG layers on QGIS

why in QGIS layers properties I read Zeroes instead of NaN?

Can you try the Python commands on your layer ?

@Gustry which Python commands you mean

The one in #571 : #571 (comment)

here are the results on a local layer as in qgis/QGIS#56541 (comment)
exported from PG

iface.activeLayer().extent().isNull()
False
iface.activeLayer().extent().isEmpty()
False

this for PG layer

iface.activeLayer().extent().isNull()
True
iface.activeLayer().extent().isEmpty()
True

@Gustry I would like to point out that, with the new check added in the 4.3.0 plugin (version), even tables without geometry are considered to have damaged spatial extension, and on layers with extension problems like in #571, even though acting as the 'Rebuild Spatial Extension' in property, this does nothing happen, and the values are always readed as NaN, moreover I adding in #571 the behaviour in mine installation of 3.36.0 that persists in 3.36.1

@Gustry manually turning NaN to Zeroes make these layers able to be published

I would like to point out that, with the new check added in the 4.3.0 plugin (version), even tables without geometry are considered to have damaged spatial extension

Sorry, yes maybe. Can you try https://packages.3liz.org/pub/lizmap-qgis-plugin/unstable/lizmap.4.3.2-alpha.zip ?

@Gustry manually turning NaN to Zeroes make these layers able to be published

I'm not sure if there is some side effect just by setting them to 0,0,0,0. I was wondering the plugin should to that.

Can you run https://postgis.net/docs/ST_EstimatedExtent.html on your table ?

@Gustry

Can you run https://postgis.net/docs/ST_EstimatedExtent.html on your table ?

what QGIS DBManager see:

Schermata del 2024-03-25 15-22-48

response of st_estimatedexent query on QGIS DBMananger

Schermata del 2024-03-25 15-23-31

as in PGAdmin

Schermata del 2024-03-25 15-27-21

Sorry, yes maybe. Can you try https://packages.3liz.org/pub/lizmap-qgis-plugin/unstable/lizmap.4.3.2-alpha.zip ?

Now it seems to works better, but all my layers are detected as invalid extent layers as in screencast

Video.del.25-03-2024.15.31.11.webm

with the project not available in repository

Schermata del 2024-03-25 15-32-11

I'm not sure if there is some side effect just by setting them to 0,0,0,0. I was wondering the plugin should to that.

in order to workaround on this I act as in below

Video.del.25-03-2024.15.35.00.webm

and this is the result its the ability to correctly publish my map including all layers recognized as invalid extension layers

Video.del.25-03-2024.15.38.08.webm

I hope I was clear in my explanation

I.e. 'limiti_comunali_local', with abnormal extent

Video.del.25-03-2024.15.57.32.webm

after substitution of NaN with zeroes

Video.del.25-03-2024.15.58.08.webm

You can at least skip the text editor : 08eab55
Please try the new version 4.3.3

after substitution of NaN with zeroes

And is-it OK as far as you can see ?

@Gustry yes! it works now, but the user needs to click a tons of ok button (twice per layer - one per layer on apply button and one per layer on ok plugin's tab button) in order to see the Lizmap plugin tab to disappear

Well, just click "Ok" :) It's saving the CFG file ...

I know, this is a temporary solution, it's to keep in mind that something might get wrong.

Right @Gustry thank you very much

It's like in any software (QGIS Desktop, other softwares) :

  • Apply : save the configuration but keep the dialog open
  • OK : save the configuration but close the dialog

@Gustry in this case 'OK' works as 'Apply' until/while all the recognized invalid extent layers (in my specific project are 22) are being configured