示例#1
0
  def lookupLabel( self, obj ):
    '''This method is used to provide a hook to allow different objects to
    generate different labels for a given object based on their perspective.
    This is used to sort of hackishly simulate a relational-type capability for
    the purposes of viewing backlinks.
   
    See the automounter map and NFS volume DBEditObject subclasses for how this
    is to be used, if you have them.
    '''
    if obj.getTypeID() == SchemaConstants.UserBase:
      fullNameField = obj['Full_Name']
      nameField = obj['Username']

      if fullNameField and nameField:
        return nameField.val + " (" + fullNameField.val + ")"

    # Mark email lists
    if obj.getTypeID() == 274:
      return BaseJythonEditObject.lookupLabel(self, obj) + " (email list)"

    # Mark external email records
    if obj.getTypeID() == 275 and obj['Targets'] != None:
      addresses = [ str(addr) for addr in obj['Targets'].val ]
      return BaseJythonEditObject.lookupLabel( self, obj ) + " (" + ", ".join(addresses) + ")"

    return BaseJythonEditObject.lookupLabel( self, obj )