Changeset 3919 for waeup/branches


Ignore:
Timestamp:
6 Feb 2009, 23:56:52 (16 years ago)
Author:
uli
Message:

Use ints as keys.

File:
1 edited

Legend:

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

    r3914 r3919  
    1212    grok.implements(IFacultyContainer)
    1313    grok.require('waeup.manageUniversity')
     14
     15    # A simple counter for ids.
     16    next_id = 0L
    1417   
    1518    def getId(self, faculty):
    1619        """We need a unified id for each faculty, which acts as key.
    1720        """
    18         id = faculty.name
    19         id = id.replace(' ', '')
    20         return id.lower()
     21        return self.next_id
    2122   
    2223    def addFaculty(self, faculty):
    2324        if not IFaculty.providedBy(faculty):
    2425            raise TypeError('FacultyContainers contain only IFaculty instances')
    25         id = self.getId(faculty)
    26         self[id] = faculty
     26        self[self.next_id] = faculty
     27        self.next_id += 1
    2728
    2829# We register FacultyContainer as a utility. This way we can
Note: See TracChangeset for help on using the changeset viewer.