swat.CAS.session_context

CAS.session_context(self, *args, **kwargs)

Create a context of session options

This method is intended to be used in conjunction with Python’s with statement. It allows you to set CAS session options within that context, then revert them back to their previous state.

For all possible session options, see the sessionprop.getsessopt CAS action documentation.

Parameters
*argsstring / any pairs

Name / value pairs of options in consecutive arguments, name / value pairs in tuples, or dictionaries.

**kwargsstring / any pairs

Key / value pairs of session options

Examples

>>> conn = swat.CAS()
>>> print(conn.getsessopt('locale').locale)
en_US
>>> with conn.session_context(locale='fr'):
...     print(conn.getsessopt('locale').locale)
fr
>>>  print(conn.getsessopt('locale').locale)
en_US