class documentation

Child class of the PContext context class that adds further functions and details.

Method __init__ Initializer for the context class.
Method doClearConsole Clear the console.
Method doCreateResource Execute a "create-resource" request to create a resource on a CSE.
Method doCseAttributeInfos Return a list of CSE attribute infos for the given attribute name. The search is done over the short and long names of the attributes using a fuzzy search when searching the long names.
Method doCseStatus Retrieve the CSE status.
Method doDeleteResource Execute a "delete-resource" request on the CSE.
Method doGetConfiguration Get a setting from the CSE's configuration.
Method doGetLogLevel Get the log level of the CSE. This will be one of the following strings:
Method doGetStorage Retrieve a value for key from the persistent storage storage.
Method doHasConfiguration Test for the existence of a key in the CSE's configuration.
Method doHasStorage Test for the existence of a key in the persistent storage.
Method doHttp Making a http(s) request.
Method doImportRaw Import a raw resource. Not much verification is done, and a full resource representation, including, for example, the parent resource ID, must be provided.
Method doLogDivider Print a divider line to the log (on DEBUG level).
Method doNotify Execute a NOTIFY request. The originator must be set before this function.
Method doOpenWebBrowser Open a web browser with the given URL.
Method doPingTcpService Ping a TCP service (server) to check if it is available and reachable.
Method doPrintJSON Print a beautified JSON to the console.
Method doPutStorage Store a value in the persistent storage.
Method doQueryResource Run a comparison query against a JSON structure. This compares to the oneM2M advanced query filtering in RETRIEVE/DISCOVERY requests.
Method doRefreshRegistrations Check and refresh the registrations to the registrars.
Method doRemoveStorage Either remove a value from the persistent storage, or remove all values from the storage with a given storage ID.
Method doReset Reset the CSE.
Method doRestart Restart the CSE. This will stop the CSE and all running services.
Method doRetrieveResource Execute a RETRIEVE request.
Method doRunScript Run another script.
Method doRunsInIPython Determine whether the CSE currently runs in an IPython environment, such as Jupyter Notebooks.
Method doRunsInTUI Determine whether the CSE currently runs in Text UI mode.
Method doScheduleNextScript Schedule the next script to run after the current script has finished.
Method doSetCategoryDescription Set the description of a category.
Method doSetConfig Set a CSE configuration. The configuration must be an existing configuration. No new configurations can be created this way.
Method doSetLogging Enable/disable the console logging.
Method doShutDown Shut down the CSE. This will stop the CSE and all running services.
Method doTuiConfirm Show a TUI confirmation dialog.
Method doTuiNotify Show a TUI notification.
Method doTuiRefreshResources Refresh the TUI resources. This will update the resource Tree and the resource details.
Method doTuiVisualBell Execute a TUI visual bell. This shortly flashes the script's menu entry.
Method doUpdateResource Execute an UPDATE request.
Method filename.setter Set the script's filename (to the filename meta information).
Method log Callback for normal log messages.
Method logError Callback for error log messages.
Method prnt Callback for print function messages.
Class Variable __slots__ Slots of class attributes.
Class Variable dispatcher Injected Dispatcher instance.
Class Variable factory Injected Factory instance.
Class Variable managementSupport Injected ManagementSupport instance.
Class Variable registration Injected RegistrationManager instance.
Class Variable requestManager Injected RequestManager instance.
Class Variable resetCSE Injected function to reset the CSE.
Class Variable scriptManager Injected ScriptManager instance.
Class Variable textUI Injected TextUI plugin, if available.
Class Variable validator Injected Validator instance.
Instance Variable fileMtime The script file's latest modified timestamp.
Instance Variable maxRuntime Number of seconds that is a script allowed to run.
Instance Variable nextScript The next script to be executed. Used for chaining scripts.
Instance Variable scriptFilename The script filename.
Property errorMessage Format and return an error message.
Property filename Return the script's filename (from the filename meta information).
Method _handleRequest Internally handle a request, either via a direct URL or through an originator.
Method _pcontextFromRequestResult Update a PContext instance from a CSE Result.
Method _validate Validate the script

Inherited from PContext:

Method arguments.setter Set the arguments for the current call scope.
Method clearEnvironment Remove all environment variables.
Method copyError Copy the error attributes from another PContext object.
Method delVariable Delete a variable for a name. If the variable exists in the global scope, it is deleted in all scopes. Otherwise, it is only deleted in the current scope.
Method getEnvironmentVariable Return an evironment variable for a case insensitive name.
Method getMeta Return the argument of meta data, or an empty string.
Method getVariables Return all variables and values which names match a regular expression.
Method hasMeta Check if a meta data key exists.
Method logSymbol Log a symbol in verbose mode to the script's log function.
Method popCall Remove a call from the stack..
Method pushCall Save various stack information to the script's call stack. This creates a new PCall object.
Method reset Reset the context / script.
Method run Run the script in the PContext instance.
Method scriptName.setter Set the name of the script in the meta data.
Method setEnvironment Clear old environment and assign a new environment.
Method setEnvironmentVariable Set an environment variable for a name.
Method setError Set the internal state and error codes.
Method setMaxRuntime Set the maximum runtime of the script.
Method setResult Set the result symbol. The difference to directly setting the result attribute is that his method return self.
Method setVariable Set a variable for a name. If the variable exists in the global scope, it is updated or set in all scopes. Otherwise, it is only updated or set in the current scope.
Instance Variable allowBrackets Allow "[" and "]" for opening and closing lists as well.
Instance Variable argv List of string that are arguments to the script.
Instance Variable ast The script's abstract syntax tree.
Instance Variable environment Dictionary of variables that are passed by the application to the script. Similar to variables, but the environment is not cleared.
Instance Variable error Error state.
Instance Variable errorFunc An optional function that is called when an error occured.
Instance Variable evaluateInline Check and execute inline expressions in strings.
Instance Variable fallbackFunc An optional function to retrieve unknown symbols from the caller.
Instance Variable functions Dictoonary of defined script functions.
Instance Variable logErrorFunc An optional function that receives error log messages.
Instance Variable logFunc An optional function that receives non-error log messages.
Instance Variable matchFunc An optional function that is used to run regex comparisons.
Instance Variable meta Dictionary of the script's meta tags and their arguments.
Instance Variable monitorFunc An optional function to monitor function calls, e.g. to forbid them during particular executions.
Instance Variable postFunc An optional function that is called after running a script.
Instance Variable preFunc An optional function that is called before running a script.
Instance Variable printFunc An optional function for printing messages to the screen, console, etc.
Instance Variable result Intermediate and final results during the execution.
Instance Variable script The script to run.
Instance Variable startupSymbols The built-in commands. This original list will be restored later during reset.
Instance Variable state The internal state of a script.
Instance Variable symbols A dictionary of new symbols / functions to add to the interpreter.
Instance Variable verbose Print more debug messages.
Property arguments Return the arguments of the current call.
Property currentCall Get the current call as a PCall object.
Property scriptName The name of the script (from the meta data).
Property variables The variables of the current scope.
Class Variable _macroMatch Regex for matching macros in strings and JSON.
Instance Variable _callStack The internal call stack (internal).
Instance Variable _maxRTimestamp The max timestamp until the script may run (internal).
def __init__(self, script: str, preFunc: PFuncCallable | None = None, postFunc: PFuncCallable | None = None, errorFunc: PFuncCallable | None = None, filename: str | None = None, fallbackFunc: PSymbolCallable = None, monitorFunc: PSymbolCallable = None, allowBrackets: bool = False):

Initializer for the context class.

Parameters
script:strA script contained in a string or a list of strings.
preFunc:PFuncCallable | NoneAn optional callback that is called with the PContext object just before the script is executed. Returning None prevents the script execution.
postFunc:PFuncCallable | NoneAn optional callback that is called with the PContext object just after the script finished execution.
errorFunc:PFuncCallable | NoneAn optional callback that is called with the PContext object when encountering an error during script execution.
filename:str | NoneThe script's filename.
fallbackFunc:PSymbolCallableUndocumented
monitorFunc:PSymbolCallableUndocumented
allowBrackets:boolAllow "[" and "]" for opening and closing lists as well.
def doClearConsole(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Clear the console.

Example

(clear-console) -> nil
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
def doCreateResource(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Execute a "create-resource" request to create a resource on a CSE.

The function has the following arguments:

  • originator of the request
  • target resource ID
  • JSON resource
  • Optional: JSON with additional request arguments

The function returns a quoted list as a result with the following symbols:

  • Response status
  • Response resource

Example

(create-resource "originator" "cse-in"  { "m2m:cnt": { "rn": "myCnt" }} [<request arguments>]) -> ( <status> <resource> )
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
def doCseAttributeInfos(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Return a list of CSE attribute infos for the given attribute name. The search is done over the short and long names of the attributes using a fuzzy search when searching the long names.

The function has the following arguments:

  • attribute name. This could be a short name or a long name.

The function returns a quoted list where each entry is another quoted list with the following symbols:

  • attribute short name
  • attribute long name
  • attribute type

Example

(cse-attribute-info "acop") -> ( ( "acop" "accessControlOperations" "nonNegInteger" ) )
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
def doCseStatus(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Retrieve the CSE status.

Example

(cse-status)
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result, ie. the CSE status as a string.
def doDeleteResource(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Execute a "delete-resource" request on the CSE.

The function has the following arguments:

  • originator of the request
  • target resource ID
  • Optional: JSON with additional request arguments

The function returns a quoted list as a result with the following symbols:

  • Response status
  • Response resource

Example

(delete-resource "originator "cse-in/myCnt" [<request arguments>]) -> ( <status> <resource> )
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
def doGetConfiguration(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Get a setting from the CSE's configuration.

Example

(get-configuration "cse.cseID") -> "id-in
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
Raises
PUndefinedErrorIn case the configuration key is undefined
def doGetLogLevel(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Get the log level of the CSE. This will be one of the following strings:

  • "DEBUG"
  • "INFO"
  • "WARNING"
  • "ERROR"
  • "OFF"

Example

(get-loglevel) -> "INFO"
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
def doGetStorage(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Retrieve a value for key from the persistent storage storage.

Example

(get-storage "aStorageID" "aKey") -> value
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
Raises
PUndefinedErrorIf the key is undefined in the persistent storage.
def doHasConfiguration(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Test for the existence of a key in the CSE's configuration.

Example

(has-config "aKey")
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result, ie. a boolean value.
def doHasStorage(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Test for the existence of a key in the persistent storage.

Example

(has-storage "aStorageID" "aKey")
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result, ie. a boolean value.
def doHttp(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Making a http(s) request.

Example

(http post "https://example.com"
        ('("aHeader" "a header value")
         '("anotherHeader" "another header value"))
        "body content")
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
Raises
PInvalidArgumentErrorIn case the operation is undefined or an invalid header definion is encountered.
def doImportRaw(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Import a raw resource. Not much verification is done, and a full resource representation, including, for example, the parent resource ID, must be provided.

Example

(import-raw <originator> <resource JSON> )
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
Raises
PRuntimeErrorIn case an error during the import and create is encountered.
def doLogDivider(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Print a divider line to the log (on DEBUG level).

Optionally add a message that is centered on the line.

Example

(log-divider "Hello, World")
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
def doNotify(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Execute a NOTIFY request. The originator must be set before this function.

The function has the following arguments:

  • originator of the request
  • target resource ID
  • JSON resource
  • Optional: JSON with additional request arguments

The function returns a quoted list as a result with the following symbols:

  • Response status
  • Response resource

Example

(send-notification <originator> <target> <resource JSON> [<headers JSON>]) -> ( <status> <resource> )
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
def doOpenWebBrowser(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Open a web browser with the given URL.

The function has the following arguments:

  • URL to open in the browser.

The function returns a boolean as a result, indicating if the browser could be opened.

Example

(open-web-browser <url>) -> boolean
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
def doPingTcpService(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Ping a TCP service (server) to check if it is available and reachable.

The function has the following arguments:

  • server name or IP address.
  • port number.
  • Optional: timeout in seconds (default: 10).

The function returns a boolean as a result, indicating if the service is reachable.

Example

(ping-service <server> <port> [<timeout>]) -> boolean
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
def doPrintJSON(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Print a beautified JSON to the console.

Nothing will be printed if the CSE is running in headless mode.

Example

(print-json { "a" : "b" })
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
def doPutStorage(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Store a value in the persistent storage.

Example

(put-storage "storageID" "aKey" "Hello, World")
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
def doQueryResource(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Run a comparison query against a JSON structure. This compares to the oneM2M advanced query filtering in RETRIEVE/DISCOVERY requests.

The first argument is an s-expression that only contains comparisons.

Example

(query-resource '(== rn "cnt1234")) { "rn": "cnt1234", "x": 123 })
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
def doRefreshRegistrations(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Check and refresh the registrations to the registrars.

Example

(refresh-registrations)
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
def doRemoveStorage(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Either remove a value from the persistent storage, or remove all values from the storage with a given storage ID.

Example

(storage-remove "aStorageID" "aKey")
(storage-remove "aStorageID")
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
def doReset(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Reset the CSE.

Example

(reset)
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
def doRestart(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Restart the CSE. This will stop the CSE and all running services.

This function returns normally, but the CSE will start to shut down after returning. The script will be stopped at any time after this function returns.

The difference to the "shutdown-cse" function is that this function will quit with a return code of 82, while the "shutdown-cse" function will quit with a return code of 0.

Example

(restart-cse) -> nil
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
def doRetrieveResource(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Execute a RETRIEVE request.

The function has the following arguments:

  • originator of the request
  • target resource ID
  • Optional: JSON with additional request arguments

The function returns a quoted list as a result with the following symbols:

  • Response status
  • Response resource

Example

(retrieve-resource "originator" "cse-in" [(<headers JSON>)] -> ( <status> <resource> )
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
def doRunScript(self, pcontext: PContext, symbol: SSymbol, isInclude: bool = False) -> PContext:

Run another script.

The result of the script is passed as the result of this function.

Example

(run-script <script name> [<arguments>]* ) -> ( <status> <resource> )
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
isInclude:boolBoolean indicator whether the script result (functions, variables) shall be added to the currently running script.
Returns
PContextThe updated PContext object with the operation result.
Raises
PUndefinedErrorIn case there is no script with that name.
PRuntimeErrorIn case the script exits with an error.
def doRunsInIPython(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Determine whether the CSE currently runs in an IPython environment, such as Jupyter Notebooks.

Example

(runs-in-ipython)
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result, ie. a boolean value.
def doRunsInTUI(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Determine whether the CSE currently runs in Text UI mode.

Example

(runs-in-tui)
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result, ie. a boolean value.
def doScheduleNextScript(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Schedule the next script to run after the current script has finished.

Example

(schedule-next-script "scriptName" "arg1" "arg2" ...)
(schedule-next-script "scriptName")
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object.
def doSetCategoryDescription(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Set the description of a category.

Example

(set-category-description "myCategory" "My category description")
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
def doSetConfig(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Set a CSE configuration. The configuration must be an existing configuration. No new configurations can be created this way.

Example

(set-config <configuration key> <value>)
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
Raises
PInvalidTypeErrorIn case the data types of the configuration setting and the new value are different from each other.
PUnsupportedErrorIn case the data type is not supported.
PInvalidArgumentErrorIn case the setting could not be updated.
PUndefinedErrorIn case the key references an undefined configuration setting.
def doSetLogging(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Enable/disable the console logging.

Example

(set-console-logging true) -> nil
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
def doShutDown(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Shut down the CSE. This will stop the CSE and all running services.

This function returns normally, but the CSE will start to shut down after returning. The script will be stopped at any time after this function returns.

Example

(shutdown-cse) -> nil
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
def doTuiConfirm(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Show a TUI confirmation dialog.

This function is only available in TUI mode. It has the following arguments.

  • text: The text to show in the confirmation dialog.
  • title: The title of the confirmation dialog.
  • confirmButtonText: (Optional) The text for the confirm button. Default: "OK".
  • cancelButtonText: (Optional) The text for the cancel button. Default: "Cancel".

The function returns a boolean value indicating whether the user confirmed or cancelled the dialog, or NIL if the dialog was closed without a selection.

Example

(tui-confirm "Do you want to continue?" "Confirmation") -> true
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
def doTuiNotify(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Show a TUI notification.

This function is only available in TUI mode. It has the following arguments.

  • message: The message to show.
  • title: (Optional) The title of the notification.
  • severity: (Optional) The severity of the notification. Can be one of the following values: information, warning, error.
  • timeout: (Optional) The timeout in seconds after which the notification will disappear. If not specified, the notification will disappear after 3 seconds.

The function returns NIL.

Example

(tui-notify "This is a notification") -> nil
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object.
def doTuiRefreshResources(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Refresh the TUI resources. This will update the resource Tree and the resource details.

Example

(tui-refresh-resources)
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object.
def doTuiVisualBell(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Execute a TUI visual bell. This shortly flashes the script's menu entry.

Example

(tui-visual-bell)
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object.
def doUpdateResource(self, pcontext: PContext, symbol: SSymbol) -> PContext:

Execute an UPDATE request.

The function has the following arguments:

  • originator of the request
  • target resource ID
  • JSON resource
  • Optional: JSON with additional request arguments

The function returns a quoted list as a result with the following symbols:

  • Response status
  • Response resource

Example

(update-resource "originator" "cse-in/myCnt" { "m2m:cnt" { "lbl": ["aLabel"] }} [<request arguments>]) -> ( <status> <resource> )
Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
Returns
PContextThe updated PContext object with the operation result.
def filename(self, filename: str):

Set the script's filename (to the filename meta information).

Parameters
filename:strThe full filename.
def log(self, pcontext: PContext, msg: str):

Callback for normal log messages.

Parameters
pcontext:PContextScript context. Not used.
msg:strlog message.
def logError(self, pcontext: PContext, msg: str, exception: Exception | None = None):

Callback for error log messages.

Parameters
pcontext:PContextScript context. Not used.
msg:strThe log message.
exception:Exception | NoneOptional exception to log.
def prnt(self, pcontext: PContext, msg: str):

Callback for print function messages.

Parameters
pcontext:PContextScript context. Not used.
msg:strThe log message.
__slots__: tuple[str, ...] =

Slots of class attributes.

dispatcher: Dispatcher =

Injected Dispatcher instance.

factory: Factory =

Injected Factory instance.

managementSupport: ManagementSupport =

Injected ManagementSupport instance.

registration: RegistrationManager =

Injected RegistrationManager instance.

requestManager: RequestManager =

Injected RequestManager instance.

resetCSE: Callable[[], None] =

Injected function to reset the CSE.

scriptManager: ScriptManager =

Injected ScriptManager instance.

textUI: TextUI | None =

Injected TextUI plugin, if available.

validator: Validator =

Injected Validator instance.

fileMtime =

The script file's latest modified timestamp.

maxRuntime =

Number of seconds that is a script allowed to run.

nextScript: tuple[PContext, list[str]] =

The next script to be executed. Used for chaining scripts.

scriptFilename =

The script filename.

@property
errorMessage: str =

Format and return an error message.

Returns
String with the error message.
@property
filename: str =

Return the script's filename (from the filename meta information).

Returns
String with the full filename.
def _handleRequest(self, pcontext: PContext, symbol: SSymbol, operation: Operation) -> PContext:

Internally handle a request, either via a direct URL or through an originator.

Return status and resources in the variables result.status and result.resource respectively.

Parameters
pcontext:PContextPContext object of the running script.
symbol:SSymbolThe symbol to execute.
operation:OperationThe operation to perform.
Returns
PContextThe updated PContext object with the operation result.
Raises
PInvalidArgumentErrorIn case the input, e.g. the resource, is incorrect.
def _pcontextFromRequestResult(self, pcontext: PContext, res: Result) -> PContext:

Update a PContext instance from a CSE Result.

Parameters
pcontext:PContextPContext object of the running script.
res:ResultResult object.
Returns
PContextThe updated PContext object with the operation result.
def _validate(self):

Validate the script

If an invalid script is detected then the state is set to invalid.