예제 #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 )
예제 #2
0
  def anonymousLinkOK( self, targetObject, targetFieldID, sourceObject,
      sourceFieldID, gsession ):
    '''
    This method is used to control whether or not it is acceptable to make a
    link to the given field in this {@link arlut.csd.ganymede.server.DBObject
    DBObject} type when the user only has editing access for the source {@link
    arlut.csd.ganymede.server.InvidDBField InvidDBField} and not the target.
   
    This version of anonymousLinkOK takes additional parameters to allow an
    object type to decide that it does or does not want to allow a link based
    on what field of what object wants to link to it.
   
    By default, the 3 variants of the DBEditObject anonymousLinkOK() method are
    chained together, so that the customizer can choose which level of detail
    he is interested in.  {@link arlut.csd.ganymede.server.InvidDBField
    InvidDBField}s {@link arlut.csd.ganymede.server.InvidDBField#bind(
    arlut.csd.ganymede.common.Invid,arlut.csd.ganymede.common.Invid,boolean)
    bind()} method calls this version.  This version calls the three parameter
    version, which calls the two parameter version, which returns false by
    default.  Customizers can implement any of the three versions, but unless
    you maintain the version chaining yourself, theres no point to
    implementing more than one of them.  
    '''
    # If someone tries to put this list in another email list, let them.
    # Type 274 is Email List, and field 257 is Members.
    if targetFieldID == SchemaConstants.BackLinksField and \
        sourceObject.getTypeID() == 274  and \
        sourceFieldID == self.MEMBERS_FIELD_ID:
      return true

    # The default anonymousLinkOK method returns false
    return BaseJythonEditObject.anonymousLinkOK( self, targetObject,
        targetFieldID, sourceObject, sourceFieldID, gsession )
예제 #3
0
 def obtainChoicesKey( self, field ):
   '''This method returns a key that can be used by the client to cache the
   value returned by choices().  If the client already has the key cached on
   the client side, it can provide the choice list from its cache rather than
   calling choices() on this object again.
  
   If there is no caching key, this method will return null.
   '''
   if field.getID() == self.MEMBERS_FIELD_ID:
     return None
   else:
     return BaseJythonEditObject.obtainChoicesKey( self, field )
예제 #4
0
 def fieldRequired( self, obj, fieldid ):
   '''
   Customization method to control whether a specified field is required to be
   defined at commit time for a given object.
  
   To be overridden in DBEditObject subclasses.
  
   Note that this method will not be called if the controlling
   GanymedeSessions enableOversight is turned off, as in bulk loading.
   '''
   # The email list name is required
   if fieldid == self.LISTNAME_FIELD_ID:
     return 1
   
   return BaseJythonEditObject.fieldRequired( self, obj, fieldid )
예제 #5
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
예제 #6
0
 def __init__( self, base, invid, editset, original ):
   BaseJythonEditObject.__init__( self, base, invid, editset, original )
   self.membersChoice = None