Zum Hauptinhalt springen
Inhaltsverzeichnis überspringen

utilities - session

The session module provides functions for getting information about a session

Functions

Function

Parameters

Return Value

Description

get_session_user(session_id)

session_id: The numerical identifier of a session

The user id for the specified session

Can raise the following exceptions:

        utilities.SessionNotFoundException when no session with the given ID exists
   

get_session_info(session_id)

session_id: The numerical identifier of a session

Returns a SessionInfo object

The SessionInfo object has the following attributes:

        SessionInfo.getUser(): Get the user id, same as server.get_session_user
        SessionInfo.getTimeStamp(): Currently unused
        SessionInfo.getSessionUUID(): Unique ID that identifies a record in DT 443.
        SessionInfo.getStartTime(): Returns a java.sql.Timestamp instance when the session was started
        SessionInfo.getEndTime(): java.sql.Timestamp instance or None if the session hasn't ended yet
        SessionInfo.getReason(): Currently unused

Can raise the following exception:

        utilities.SessionNotFoundException when no session with the given ID exists
      

open_clientless_session(user)

 user: The user logged into the session

Returns a unique ID of the new clientless session

Starts a clientless session on behalf of a user

The session stays open until closeClientlessSession is called.

Can raise the following exception:
        utilities.SessionNotFoundException when no session with the given ID exists

close_clientless_session(clientless_session_id)

Closes a clientless session

Can raise the following exception:

        utilities.SessionNotFoundException when no session with the given ID exists

Classes

ClientlessSession

Class

Parameters

Description

ClientlessSession(user)

 user: The user logged into the session

Context manager for clientless sessions

The clientless session is sent a shutdown command when the context is left. If there are still modules running in the session they first need to conclude before the session is shutdown.

Example usage:
        Opening module 100000 in a new session as R41 and reading the return value from on_web_load()

PY
from customizing import utilities
with utilities.ClientlessSession('R41') as session:
   session.open_module(module_id='100000')
   data = session.get_return_value(module_id='100000', timeout=5)

Methods

Function

Parameters

Return values

Description

ClientlessSession.open_module(self, module_id, parameters=None)

module_id: The ID of the module to open

parameters: An optional dictionary of parameters that will be passed to on_web_load function of the module

Open a module in the specified clientless sessios

Can raise the following exceptions:

utilities.ClientlessSessionNotFoundException

utilities.ModuleNotFoundException

utilities.ModuleDictionaryException

ClientlessSession.get_return_value(self, module_id, timeout=None)

module_id: The ID of the module that was opened and should be polled

timeout: Amount of seconds to wait until timing out

Fetches the return value of a module in the specified clientless session

Fetches the return value of on_web_load() from the opened module.

  • If the timeout is reached, None will be returned.

  • If no timeout was specified, the default value from the global setting jython_module_return_timeout is used.

  •  If the module has no on_web_load()defined, an empty dictionary is returned.

Can raise the following exceptions:

utilities.ClientlessSessionNotFoundException

utilities.ModuleDictionaryException

PersistentClientlessSession

Class

Parameters

Description

PersistentClientlessSession(user)

 user: The user logged into the session

Context manager for persistent clientless sessions

In contrast to the ClientlessSession context manager, where the session is exited when the context is exited, with PersistentClientlessSession the session remains open when the context is exited.

Methods

Function

Parameters

Return values

Description

PersistentClientlessSession.open_module(self, module_id, parameters=None)

module_id: The ID of the module to open

parameters: An optional dictionary of parameters that will be passed to on_web_load function of the module

Open a module in the persistent clientless session. This method only accepts macro modules, as modules of other classes would not be cleaned up properly.

Can raise the following exceptions:

utilities.ClientlessSessionNotFoundException

utilities.ModuleNotFoundException

utilities.ModuleDictionaryException

PersistentClientlessSession.get_return_value(self, module_id, timeout=None)

module_id: The ID of the module that was opened and should be polled

timeout: Amount of seconds to wait until timing out

Fetches the return value of a module in the specified persistent clientless session

Fetches the return value of on_web_load() from the opened module.

  • If the timeout is reached, None will be returned.

  • If no timeout was specified, the default value from the global setting jython_module_return_timeout is used.

  •  If the module has no on_web_load()defined, an empty dictionary is returned.

Can raise the following exceptions:

utilities.ClientlessSessionNotFoundException

utilities.ModuleDictionaryException

PersistentClientlessSession.close_clientless_session(self)

Closes the clientless session if it is still open

Functions

Function

Parameters

Return Value

Description

get_user_context()

    

Gets the current user context of this jython session

set_user_context(user)

Sets the current user context of this jython session

Classes

Class

Description

UserContext(object)

  

Context manager for setting the user context of the current jython session

Example usage:
        Creating a project as R41 with object protection set:

PY
from customizing import utilities
with utilities.UserContext('R41'):
    pojo = utilities.create_pojo('Project', attributes={})
    utilities.save_pojo(pojo)

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.