示例#1
0
  def obtainChoiceList( self, field ):
    '''This method provides a hook that can be used to generate choice lists
    for invid and string fields that provide such.  String and Invid DBFields
    will call their owner's obtainChoiceList() method to get a list of valid
    choices.
   
    This method will provide a reasonable default for targetted invid fields.
    '''
    if field.getID() != self.MEMBERS_FIELD_ID:
      return BaseJythonEditObject.obtainChoiceList( self, field )

    if self.membersChoice is None:
      # we want to present a list of all users, mail groups besides this one,
      # and external mail aliases (email addresses that have local aliases in
      # ARL's mail system) as valid choices for the MEMBERS field.
      
      # List all users
      query1 = Query( SchemaConstants.UserBase, None, 0 )

      # List all external email targets
      query2 = Query( 275, None, 0 )

      # List all other email groups, but not ourselves
      root3 = QueryNotNode( QueryDataNode(-2, QueryDataNode.EQUALS, self.getInvid()) )
      query3 = Query( 274, root3, 0 )

      # We need a handle to the GSession to execute queries
      gsession = self.editset.getSession().getGSession()

      result = gsession.query(query1, self)
      result.append( gsession.query(query2, self) )
      result.append( gsession.query(query3, self) )

      self.membersChoice = result

    return self.membersChoice