Jam.py documentation

session

session

domain: server

language: python

class AbstractItem class

Description

Use the session property to get access to session object of the current request from the client.

The session is a dictionary that has the following items:

  • ip - ip address of the user

  • user_info - dictionary containing information about the user

    • user_id - id identifying the user

    • user_name - name of the user

    • role_id - id of user role

    • role_name - name of user role

Example

def on_open(item, params):
    user_id = item.session['user_info']['user_id']
    if user_id:
        params['__filters'].append(['user_id', item.task.consts.FILTER_EQ, user_id])

def on_apply(item, delta, params):
    user_id = item.session['user_info']['user_id']
    if user_id:
      for d in delta:
          d.edit()
          d.user_id.value = user_id
          d.post()