Ignore:
Timestamp:
7 Feb 2009, 00:03:27 (16 years ago)
Author:
uli
Message:

Be smart when looking for new ids.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/branches/ulif-rewrite/src/waeup/university/facultycontainer.py

    r3919 r3920  
    1919        """We need a unified id for each faculty, which acts as key.
    2020        """
    21         return self.next_id
     21        return str(self.next_id)
    2222   
    2323    def addFaculty(self, faculty):
    2424        if not IFaculty.providedBy(faculty):
    2525            raise TypeError('FacultyContainers contain only IFaculty instances')
    26         self[self.next_id] = faculty
    27         self.next_id += 1
     26        id = self.getId(faculty)
     27        self[id] = faculty
     28        while self.next_id in self.keys():
     29            # Look for next unused int...
     30            self.next_id += 1
     31        return id
    2832
    2933# We register FacultyContainer as a utility. This way we can
Note: See TracChangeset for help on using the changeset viewer.