parameters: (self, group, key, required_access, value=None, is_match=False, default="edit")
docstring: Check the access level of the user for a given group of rule and category key
              group - rule category like built-in or element
              key - string or list of dictiorary like view_side_bar or ['search_type':'sthpw/task', 'project','main']
              required_access - speific access level like allow, deny, edit, view, delete
docstring_summary: Check the access level of the user for a given group of rule and category key
              group - rule category like built-in or element
              key - string or list of dictiorary like view_side_bar or ['search_type':'sthpw/task', 'project','main']
              required_access - speific access level like allow, deny, edit, view, delete
docstring_tokens: Check the access level of the user for a given group of rule and category key group - rule category like built - in or element key - string or list of dictiorary like view_side_bar or [ search_type : sthpw / task project main ] required_access - speific access level like allow deny edit view delete
function: def check_access(self, group, key, required_access, value=None, is_match=False, default="edit"):
          '''Check the access level of the user for a given group of rule and category key
              group - rule category like built-in or element
              key - string or list of dictiorary like view_side_bar or ['search_type':'sthpw/task', 'project','main']
              required_access - speific access level like allow, deny, edit, view, delete'''
  
          if self.is_admin() or Sudo.is_sudo():
              return True
  
          if Sudo.is_sudo():
              return True
  
  
          if isinstance(key, basestring):
              from pyasm.biz import Project
              # order of keys shouldn't matter
              if group == 'project':
                  key = [{'code': key}, {'code': '*'}]
              else:
                  key = [{'key': key, 'project': Project.get_project_code()}, {'key': key, 'project': '*'}]
              #key = [ {'key': key, 'project': '*'}, {'key': key, 'project': Project.get_project_code()}]
          
          # if a list of keys is provided, then go through each key
          if isinstance(key, list):
              # use default only on the last item in list
              for idx, item in enumerate(key):
                  use_default = idx == len(key) - 1
                  if use_default:
                      rule_default = default
                  else:
                      rule_default = None
                  user_access = self.get_access(group, item, default=rule_default)
                 
                  if user_access != None:
                      break
          else:
              if value:
                  key = "%s||%s" % (key, value)
                  
              user_access = self.get_access(group, key)
  
  
          # this means that there are now rules defined for this
          if user_access == None:
              user_access = default
  
          # ignore value checks in the summary (way too many)
          if not value:
              if not isinstance(key, basestring):
                  key = str(key)
              self.summary[key] = "%s | %s" % (required_access, user_access)
  
          # convert access to integers
          required_access = self._get_access_enum(required_access)
          user_access = self._get_access_enum(user_access)
  
  
          
          if is_match:
              if user_access == required_access:
                  return True
              else:
                  return False
  
          if user_access >= required_access:
              return True
          else:
              return False
function_tokens: def check_access ( self , group , key , required_access , value = None , is_match = False , default = "edit" ) : if self . is_admin ( ) or Sudo . is_sudo ( ) : return True if Sudo . is_sudo ( ) : return True if isinstance ( key , basestring ) : from pyasm . biz import Project # order of keys shouldn't matter if group == 'project' : key = [ { 'code' : key } , { 'code' : '*' } ] else : key = [ { 'key' : key , 'project' : Project . get_project_code ( ) } , { 'key' : key , 'project' : '*' } ] #key = [ {'key': key, 'project': '*'}, {'key': key, 'project': Project.get_project_code()}] # if a list of keys is provided, then go through each key if isinstance ( key , list ) : # use default only on the last item in list for idx , item in enumerate ( key ) : use_default = idx == len ( key ) - 1 if use_default : rule_default = default else : rule_default = None user_access = self . get_access ( group , item , default = rule_default ) if user_access != None : break else : if value : key = "%s||%s" % ( key , value ) user_access = self . get_access ( group , key ) # this means that there are now rules defined for this if user_access == None : user_access = default # ignore value checks in the summary (way too many) if not value : if not isinstance ( key , basestring ) : key = str ( key ) self . summary [ key ] = "%s | %s" % ( required_access , user_access ) # convert access to integers required_access = self . _get_access_enum ( required_access ) user_access = self . _get_access_enum ( user_access ) if is_match : if user_access == required_access : return True else : return False if user_access >= required_access : return True else : return False