51Degrees Pipeline for Python

fiftyone_pipeline_core.javascriptbuilder Namespace Reference

Classes

class  JavaScriptBuilderEvidenceKeyFilter
class  JavascriptBuilderElement
 The JavaScriptBuilder aggregates JavaScript properties from FlowElements in the Pipeline. More...

Functions

 is_valid_object_name (name)
 Whether a name can be used as the client side object's name.
 parse_sequence (value)
 A sequence as a positive 32 bit integer.
 get_sequence (value)
 The sequence to render into the script.
 get_session_id (value)
 The session id to render into the script.
 url_encode (value)
 Encode a parameter key or value the way the .NET builder does, with WebUtility.UrlEncode.

Variables

list EXCLUDED_PARAMETERS = ["query.session-id", "query.sequence"]
 OBJECT_NAME_PATTERN = re.compile(r"[A-Za-z_$][A-Za-z0-9_$]*")
 RESERVED_WORDS
int DEFAULT_SEQUENCE = 1
int MAX_SEQUENCE = 2 ** 31 - 1
 MAX_SEQUENCE_DIGITS = len(str(MAX_SEQUENCE))
 SEQUENCE_PATTERN = re.compile(r"[ \t\n\r\f\v]*\+?([0-9]+)[ \t\n\r\f\v]*")
 SESSION_ID_PATTERN = re.compile(r"[A-Za-z0-9-]{1,64}")

Function Documentation

◆ get_sequence()

get_sequence ( value)

The sequence to render into the script.

The template writes the sequence as bare code (var sequence = ...;), so anything other than a whole number would stop the script parsing, or change what it does. A pipeline without a SequenceElement passes the query string's value, or nothing at all, straight through. As the pipeline specification says, a value that is not a positive 32 bit integer becomes 1.

@type value: object

Parameters
valueThe query.sequence evidence, or None @rtype: int
Returns
: The sequence to render

◆ get_session_id()

get_session_id ( value)

The session id to render into the script.

The template writes the session id inside quotes without any escaping. As the pipeline specification says, a session id that is not 1 to 64 ASCII letters, digits and hyphens is rendered as an empty string, whether it came from the SequenceElement or from the query string.

@type value: object

Parameters
valueThe query.session-id evidence, or None @rtype: str
Returns
: The session id to render, or an empty string

◆ is_valid_object_name()

is_valid_object_name ( name)

Whether a name can be used as the client side object's name.

@type name: object

Parameters
nameThe name to check @rtype: bool
Returns
: True if the name is a JavaScript identifier made of ASCII letters, digits, '_' and '$' that does not start with a digit and is not one of RESERVED_WORDS

◆ parse_sequence()

parse_sequence ( value)

A sequence as a positive 32 bit integer.

@type value: object

Parameters
valueThe query.sequence evidence, or None @rtype: int
Returns
: The sequence, or None when the value is not a whole number from 1 to 2147483647. Any value at all can be passed, including one a page supplied, and none of them raises.

◆ url_encode()

url_encode ( value)

Encode a parameter key or value the way the .NET builder does, with WebUtility.UrlEncode.

A space becomes '+', letters, digits and "-_.!*()" are left alone, and everything else is percent encoded. The script joins the parameters into its request body without encoding them again, so an unencoded '&' or '=' would split a value into extra fields.

@type value: object

Parameters
valueThe key or value to encode @rtype: string
Returns
: The encoded text

Variable Documentation

◆ DEFAULT_SEQUENCE

int fiftyone_pipeline_core.javascriptbuilder.DEFAULT_SEQUENCE = 1

◆ EXCLUDED_PARAMETERS

list fiftyone_pipeline_core.javascriptbuilder.EXCLUDED_PARAMETERS = ["query.session-id", "query.sequence"]

◆ MAX_SEQUENCE

int fiftyone_pipeline_core.javascriptbuilder.MAX_SEQUENCE = 2 ** 31 - 1

◆ MAX_SEQUENCE_DIGITS

fiftyone_pipeline_core.javascriptbuilder.MAX_SEQUENCE_DIGITS = len(str(MAX_SEQUENCE))

◆ OBJECT_NAME_PATTERN

fiftyone_pipeline_core.javascriptbuilder.OBJECT_NAME_PATTERN = re.compile(r"[A-Za-z_$][A-Za-z0-9_$]*")

◆ RESERVED_WORDS

fiftyone_pipeline_core.javascriptbuilder.RESERVED_WORDS
Initial value:
= frozenset([
"await", "break", "case", "catch", "class", "const", "continue",
"debugger", "default", "delete", "do", "else", "enum", "export",
"extends", "false", "finally", "for", "function", "if", "implements",
"import", "in", "instanceof", "interface", "let", "new", "null",
"package", "private", "protected", "public", "return", "static",
"super", "switch", "this", "throw", "true", "try", "typeof", "var",
"void", "while", "with", "yield",
"Infinity", "NaN", "undefined", "fiftyoneDegreesManager"])

◆ SEQUENCE_PATTERN

fiftyone_pipeline_core.javascriptbuilder.SEQUENCE_PATTERN = re.compile(r"[ \t\n\r\f\v]*\+?([0-9]+)[ \t\n\r\f\v]*")

◆ SESSION_ID_PATTERN

fiftyone_pipeline_core.javascriptbuilder.SESSION_ID_PATTERN = re.compile(r"[A-Za-z0-9-]{1,64}")