3liz / lizmap-plugin

Lizmap plugin for QGIS, allowing to publish QGIS maps to Lizmap Web Client
https://www.lizmap.com/
GNU General Public License v2.0
61 stars 30 forks source link

Python error on new project with old files #572

Closed Antoviscomi closed 1 month ago

Antoviscomi commented 3 months ago

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 :

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

Antoviscomi commented 3 months ago

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)

Gustry commented 3 months ago

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.

Antoviscomi commented 3 months ago

@Gustry I'm just analize the layers/group, deleting one by one, finally when remain only the layer '_landuse' 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)

Gustry commented 3 months ago

@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.

Gustry commented 3 months ago

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 ...

Antoviscomi commented 3 months ago

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

Antoviscomi commented 3 months ago

@Gustry so I close this topic

Antoviscomi commented 3 months ago

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

Antoviscomi commented 3 months ago

@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

Antoviscomi commented 3 months ago

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

Gustry commented 3 months ago

(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

Antoviscomi commented 3 months ago

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

Antoviscomi commented 3 months ago

@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 '_limiticomunali' (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

Gustry commented 3 months ago

@Antoviscomi As I said yesterday :

which might be from https://github.com/3liz/lizmap-plugin/issues/571 which is from QGIS 3.36. Please

Gustry commented 3 months ago

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

image

Antoviscomi commented 3 months ago

@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!

Gustry commented 3 months ago

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

Antoviscomi commented 3 months ago

@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?

Gustry commented 3 months ago

@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 ?

Antoviscomi commented 3 months ago

@Gustry which Python commands you mean

Gustry commented 3 months ago

The one in #571 : https://github.com/3liz/lizmap-plugin/issues/571#issuecomment-1997060838

Antoviscomi commented 3 months ago

here are the results on a local layer as in https://github.com/qgis/QGIS/issues/56541#issuecomment-2011874264 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
Antoviscomi commented 3 months ago

@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

Antoviscomi commented 3 months ago

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

Gustry commented 3 months ago

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 ?

Antoviscomi commented 3 months ago

@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

Antoviscomi commented 3 months ago

I.e. _'limiti_comunalilocal', 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

Gustry commented 3 months ago

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

after substitution of NaN with zeroes

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

Antoviscomi commented 3 months ago

@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

Gustry commented 3 months ago

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.

Antoviscomi commented 3 months ago

Right @Gustry thank you very much

Gustry commented 3 months ago

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

Antoviscomi commented 3 months ago

@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

github-actions[bot] commented 1 month ago

Hiya! This issue has gone quiet. 👻 We get a few issues, so we currently close issues after 60 days of inactivity. If we missed this issue or if you want to keep it open, please reply here. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Thanks for being a part of the Lizmap community! 🦎

Gustry commented 1 month ago

Fixed in 3.36.3