Skip to main content
Version: 16.12.0

policies

WordSearch

class WordSearch(Policy)

A content management policy for Word Search.

WordSearch(default="allow", config={ "textSearchConfig": { "@libVersion": "core2", "textList": [ {"name": "textItem", "switches": [ {"name": "text", "value": "generic"}, {"name": "textSetting", "@replacementChar": "*", "value": "redact"}, ]}, ] } })

__init__

def __init__(default: str = "allow", config: dict = {})

add_textItem

def add_textItem(text: str,
replacementChar: str,
textSetting: str = "redact",
**kwargs)

Adds a textItem to the textSearchConfig textList subelements.

remove_textItem

def remove_textItem(text: str)

Removes a textItem from the textSearchConfig textList subelements.

Rebuild

class Rebuild(Policy)

A content management policy for Rebuild.

__init__

def __init__(default: str = "sanitise", config: dict = {})

Editor

class Editor(Policy)

A content management policy for Editor.

When used with the Editor library's set_content_management_policy, the engine's default policy settings are queried via GW2GetPolicySettings. If 'default' is specified, it is applied to all content switches. Any explicit overrides from 'config' are applied on top. If 'default' is None, the engine's own default values are used unmodified.

Arguments:

  • default Optional[str] - Default None. The value to set all content switches to (e.g. "sanitise", "allow", "disallow"). If None, the engine's own default values are used unmodified.
  • config dict - Explicit overrides for specific config elements and switches. e.g. {"pdfConfig": {"metadata": "allow"}}

__init__

def __init__(default: Optional[str] = None, config: dict = {})

ArchiveManager

class ArchiveManager(Policy)

A content management policy for ArchiveManager.

Arguments:

  • default str - The default action to be performed. (allow, disallow, sanitise)
  • default_archive_manager str - The default action to be performed for archiveConfig. (no_action, discard, process)
  • config dict - Additional configuration settings passed to the ConfigElement with the same name as the key.

Example:

ArchiveManager( default="allow", default_archive_manager="process", config={

  • "pdfConfig" - {"embeddedImages": "disallow"},
  • "wordConfig" - {"embeddedImages": "disallow"},
  • "archiveConfig" - {
  • "@recursionDepth" - "100",
  • "jpeg" - "discard" } } )

__init__

def __init__(default: str = "sanitise",
default_archive_manager: str = "process",
config: dict = {})

Policy

class Policy()

A Content Management Policy made up of a list of ConfigElement instances.

__init__

def __init__(config_elements: list = [],
default: Optional[str] = None,
default_config_elements: list = [],
config: dict = {},
**kwargs)

__str__

def __str__()

__getattr__

def __getattr__(name)

text

@property
def text()

String representation of XML.

encode

def encode(*args)

UTF-8 encoded string representation of XML.

get_config_element_names

def get_config_element_names()

Returns a sorted list of unique ConfigElement.name values from self.config_elements.

remove_switch

def remove_switch(config_element: Union[ConfigElement, str],
switch: Union[Switch, str])

Removes all Switch instances from config_element.switches that match arg "switch" where the ConfigElement instance in self.config_elements matches arg "config_element".

Arguments:

  • config_element Union[ConfigElement, str] - A ConfigElement instance or ConfigElement.name to match.
  • switch Union[Switch, str] - A Switch instance or Switch.name to match.

Returns:

self

Raises:

  • glasswall.content_management.errors.config_elements.ConfigElementNotFound - The config_element was not found.
  • glasswall.content_management.errors.switches.SwitchNotFound - The switch was not found.

add_switch

def add_switch(config_element: Union[ConfigElement, str],
switch: Switch,
replace: bool = True)

Adds a Switch to any ConfigElement in self.config_elements that matches arg "config_element".

Arguments:

  • config_element Union[ConfigElement, str] - A ConfigElement instance or str to match ConfigElement.name.
  • switch Switch - A Switch instance.
  • replace bool, optional - Default True. Deletes any pre-existing Switch with the same .name attribute as arg "switch" within a ConfigElement that matches arg "config_element".

Returns:

self

Raises:

  • glasswall.content_management.errors.config_elements.ConfigElementNotFound - The config_element was not found.

remove_config_element

def remove_config_element(config_element: Union[ConfigElement, str])

Removes all ConfigElement instances from self.config_elements that match arg "config_element".

Arguments:

  • config_element Union[ConfigElement, str] - A ConfigElement instance or ConfigElement.name attribute to match.

Returns:

self

Raises:

  • glasswall.content_management.errors.config_elements.ConfigElementNotFound - The config_element was not found.

add_config_element

def add_config_element(config_element: ConfigElement, replace=True)

Adds a ConfigElement instance to self.config_elements.

Arguments:

  • config_element ConfigElement - A ConfigElement instance.
  • replace bool, optional - Default True. Deletes any pre-existing ConfigElement with the same .name attribute in self.config_elements.

Returns:

self

get_attributes

@staticmethod
def get_attributes(dictionary: dict)

Returns attributes from arg "dictionary". Attributes are key value pairs that have a key starting with "@". The "@" is excluded in the returned keys.

get_switches

@staticmethod
def get_switches(dictionary: dict)

Returns switches from arg "dictionary". Switches are key value pairs that do not have a key starting with "@".

from_string

@staticmethod
def from_string(string: str)

Create Policy object from string.

Arguments:

  • string str - A string representation of an xml content management policy, or a file path.

Returns:

  • new_policy glasswall.content_management.policies.Policy - A Policy object.