Changeset 9135


Ignore:
Timestamp:
31 Aug 2012, 15:14:21 (12 years ago)
Author:
Henrik Bettermann
Message:

Use getattr function instead of get method.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/students
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_vocabularies.py

    r9134 r9135  
    2828        cert.end_level = 500
    2929        self.certificate = cert
    30 
    31     def get(self, attr, default=None):
    32         try:
    33             return self.__getattribute__(attr)
    34         except AttributeError:
    35             return default
    3630
    3731class VocabularyTests(unittest.TestCase):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/vocabularies.py

    r9133 r9135  
    3737
    3838def study_levels(context):
    39     if context.get('certificate', None) is not None:
    40         start_level = int(context.certificate.start_level)
    41         end_level = int(context.certificate.end_level)
     39    certificate = getattr(context, 'certificate', None)
     40    if  certificate is not None:
     41        start_level = int(certificate.start_level)
     42        end_level = int(certificate.end_level)
    4243        if start_level == 999 or end_level == 999:
    4344            levels = [999]
     
    6970
    7071    def getTitle(self, context, value):
    71         if context.get('certificate', None) is not None:
    72             start_level = int(context.certificate.start_level)
    73             end_level = int(context.certificate.end_level)
     72        certificate = getattr(context, 'certificate', None)
     73        if certificate is not None:
     74            start_level = int(certificate.start_level)
     75            end_level = int(certificate.end_level)
    7476        else:
    7577            # default level range
Note: See TracChangeset for help on using the changeset viewer.