Up | ScorpionEx.py | SetValue | GetValue | SetConfigValue | GetConfigValue | GetImageMatr | DecimateMatr | RegisterCallback | RegisterPlugin | RegisterUserManager | PluginChanged | ExecuteCmd | Other

 

  

 
RegisterUserManager

UserManager is a specialized Python plugin for user management in Scorpion. The UserManager replaces the PIN protected dialogs for Settings and Service modes and gives the users operational rights.

Syntax:

RegisterUserManager(instance,unregisterMethod)

The UserManager plugin must implement two methods, logon and queryAccess

  • logon(self,user) where the user (string) is current user. The logon method is called after profile configuration is loaded and Scorpion is initialized, and when the user clicks the 'Logon' button in the toolbar.

  • queryAccess(self,attr,user) where the attr (string) is name of requested right and the user (string) is name of current user.

Implemented access attributes:

  • Start - gives current user rights to start

  • Stop - gives current user rights stop

  • Close -  gives current user rights to close the application

  • Settings - gives current user rights to enter Settings mode

  • Service - gives current user rights to enter Service mode

The UserManager plugin is subclassed from the standard plugin class and may register callbacks as standard plugins.

 

A simple UserManager class - defines three

#security attributes in Scorpion 7.0.0.396
_attr = ('Start','Stop','Close','Settings','Service')
#The UserManager class
class UserManager:
  def __init__(self):
    self.users=('guest','operator','technician','admin')
    self.passwords=('guest','oper','service','admin')
    self.rights=(
      (),                           #guest
      (_attr[0],_attr[1],_attr[2]), #operator
      (_attr[3]),                   #technician
      _attr                         #admin
    )
  def logon(self,user):
    #print self,'logon',user
    while True:
      ok,user,pw=LogonDialog(self.users,user,0) #trailing '0' hides cancel button
      if ok:
        for i in range(len(self.users)):
          if user==self.users[i]:
            if pw==self.passwords[i]:
              return True,user
  def queryAccess(self,attr,user):
    #print self,'queryAccess',user,attr
    for i in range(len(self.users)):
      if user==self.users[i]:
        return attr in self.rights[i]
    return False
#Central Start code
RegisterUserManager(UserManager())
 

Scorpion Vision Version XII : Build 646 - Date: 20170225
Scorpion Vision Software® is a registered trademark of Tordivel AS.
Copyright © 2000 - 2017 Tordivel AS.