3

I've got a *.qgs project I have to publish in QGIS server with 60 layers. I don't want to publish every fields so I made a processing script to exclude them using QgsVectorLayer.setExcludeAttributesWMS() and QgsVectorLayer.setExcludeAttributesWFS().

I would like to know how to do the opposite, a kind of setIncludeAttributesWFS.

##WMS=group

from qgis.core import *
from PyQt4.QtCore import *

myRegistry = QgsMapLayerRegistry.instance().mapLayers()

myList=[]

for layer in myRegistry.values():
    if (layer.type() == QgsMapLayer.VectorLayer):
        #default cleanning
        myList[:] = []

        fields = layer.pendingFields()

        for field in attributs:
                if field .name() != 'type':
                myList.append(field.name())

        #exclude WFS/WMS
        layer.setExcludeAttributesWMS(myList)
        layer.setExcludeAttributesWFS(myList)
  • Use an opposite condition. If NOT List2include --> setExcludeAttributes.... – jlSta Feb 17 '17 at 7:01
  • yes, but in my case, the wms/wfs boxes are unchecked in the properies panel. And I want them to be checked back. I think a setIncludeAttributes function is missing. – aurel_nc Feb 20 '17 at 4:18
  • Ans what i you check All than un check? NOT the best practice i know but a workaround – jlSta Feb 20 '17 at 6:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.