.. meta:: :description: Code snippets switch state current context How to switch state of current context ====================================== In this example we will show how to change the state of the current context. Let's print all known states:: from ORSServiceClass.OrsPlugin.abstractPlugin import AbstractPlugin from ORSServiceClass.OrsPlugin.allOrsNonPythonPlugins import * from ORSServiceClass.OrsPlugin.allOrsPythonPlugins import * from ORSServiceClass.OrsPlugin.allCurrentUserPythonPlugins import * from ORSServiceClass.OrsPlugin.allAllUsersPythonPlugins import * allPlugin = AbstractPlugin.getAllSubclasses() allState = list() for aPlugin in allPlugin: for aState in aPlugin.stateDescriptors: allState.append(aState.state) print(allState) Now let's switch the current context to the OrsStateTrack state:: from ORSServiceClass.OrsPlugin.abstractContext import AbstractContext from OrsLibraries.workingcontext import WorkingContext WorkingContext.setCurrentGlobalState(AbstractContext.getCurrentContext(), 'OrsStateTrack' ) You should see that the current state is now Track