Class: QgsAccessControl

class qgis.server.QgsAccessControl

Bases: QgsFeatureFilterProvider

A helper class that centralizes restrictions given by all the access control filter plugins.

New in version 2.14.

QgsAccessControl() Constructor

QgsAccessControl(copy: QgsAccessControl) Constructor

Methods

allowToEdit

Are we authorized to modify the following geometry

clone

Returns a clone of the object

extraSubsetString

Returns an additional subset string (typically SQL) filter

fillCacheKey

Fill the capabilities caching key

filterFeatures

Filter the features of the layer

layerAttributes

Returns the authorized layer attributes

layerDeletePermission

Returns the layer delete right

layerInsertPermission

Returns the layer insert right

layerReadPermission

Returns the layer read right

layerUpdatePermission

Returns the layer update right

registerAccessControl

Register an access control filter

resolveFilterFeatures

Resolve features' filter of layers The method fetch filter's expressions returned from access control plugins and and combine them to a unique expression for each layer.

unresolveFilterFeatures

Clear expression's cache computed from resolveFilterFeatures

allowToEdit(self, layer: QgsVectorLayer, feature: QgsFeature) bool

Are we authorized to modify the following geometry

Parameters:
Return type:

bool

Returns:

True if we are allowed to edit the feature

clone(self) QgsFeatureFilterProvider

Returns a clone of the object

Return type:

QgsFeatureFilterProvider

Returns:

A clone

extraSubsetString(self, layer: QgsVectorLayer) str

Returns an additional subset string (typically SQL) filter

Parameters:

layer (QgsVectorLayer) – the layer to control

Return type:

str

Returns:

the subset string to use

fillCacheKey(self, cacheKey: Iterable[str]) bool

Fill the capabilities caching key

Parameters:

cacheKey (Iterable[str]) – the list to fill with a cache variant

Return type:

bool

filterFeatures(self, layer: QgsVectorLayer, filterFeatures: QgsFeatureRequest)

Filter the features of the layer

Parameters:
layerAttributes(self, layer: QgsVectorLayer, attributes: Iterable[str]) List[str]

Returns the authorized layer attributes

Parameters:
  • layer (QgsVectorLayer) – the layer to control

  • attributes (Iterable[str]) – the list of attribute

Return type:

List[str]

Returns:

the list of visible attributes

layerDeletePermission(self, layer: QgsVectorLayer) bool

Returns the layer delete right

Parameters:

layer (QgsVectorLayer) – the layer to control

Return type:

bool

Returns:

True if we can do a delete

layerInsertPermission(self, layer: QgsVectorLayer) bool

Returns the layer insert right

Parameters:

layer (QgsVectorLayer) – the layer to control

Return type:

bool

Returns:

True if we can insert on it

layerReadPermission(self, layer: QgsMapLayer) bool

Returns the layer read right

Parameters:

layer (QgsMapLayer) – the layer to control

Return type:

bool

Returns:

True if it can be read

layerUpdatePermission(self, layer: QgsVectorLayer) bool

Returns the layer update right

Parameters:

layer (QgsVectorLayer) – the layer to control

Return type:

bool

Returns:

True if we can do an update

registerAccessControl(self, accessControl: QgsAccessControlFilter, priority: int = 0)

Register an access control filter

Parameters:
  • accessControl (QgsAccessControlFilter) – the access control to add

  • priority (int = 0) – the priority used to define the order

resolveFilterFeatures(self, layers: Iterable[QgsMapLayer])

Resolve features’ filter of layers The method fetch filter’s expressions returned from access control plugins and and combine them to a unique expression for each layer. The resulted expressions are stored in cache for efficiency; between each requests, the cache must be cleared using ‘unresolveFilterFeatures()’.

Parameters:

layers (Iterable[QgsMapLayer]) – to filter

unresolveFilterFeatures(self)

Clear expression’s cache computed from resolveFilterFeatures