Changeset 9701


Ignore:
Timestamp:
20 Nov 2012, 11:16:38 (12 years ago)
Author:
Henrik Bettermann
Message:

Replace 'has_key' by 'in'

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/accesscodes/batching.py

    r9269 r9701  
    146146        errs, inv_errs, conv_dict =  converter.fromStringDict(
    147147            row, self.factory_name, mode=mode)
    148         if row.has_key('transition') and row.has_key('state'):
     148        if 'transition' in row and 'state' in row:
    149149            if row['transition'] not in (IGNORE_MARKER, '') and \
    150150                row['state'] not in (IGNORE_MARKER, ''):
    151151                errs.append(('workflow','not allowed'))
    152152                return errs, inv_errs, conv_dict
    153         if row.has_key('transition'):
     153        if 'transition' in row:
    154154            if row['transition'] not in IMPORTABLE_TRANSITIONS:
    155155                if row['transition'] not in (IGNORE_MARKER, ''):
    156156                    errs.append(('transition','not allowed'))
    157         if row.has_key('state'):
     157        if 'state' in row:
    158158            if row['state'] not in IMPORTABLE_STATES:
    159159                if row['state'] not in (IGNORE_MARKER, ''):
     
    188188        # Update state
    189189        # Attention: When importing states the counters remain unchanged.
    190         if row.has_key('state'):
     190        if 'state' in row:
    191191            state = row.get('state', IGNORE_MARKER)
    192192            if state not in (IGNORE_MARKER, ''):
     
    198198            row.pop('state')
    199199        # Trigger transition. Counters are properly changed.
    200         if row.has_key('transition'):
     200        if 'transition' in row:
    201201            transition = row.get('transition', IGNORE_MARKER)
    202202            if transition not in (IGNORE_MARKER, ''):
     
    209209        # random_num string to avoid annoying automatic number transformation
    210210        # by Excel or Calc
    211         if row.has_key('random_num'):
     211        if 'random_num' in row:
    212212            random_num = row.get('random_num', IGNORE_MARKER)
    213213            if random_num not in (IGNORE_MARKER, ''):
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/batching.py

    r9250 r9701  
    226226        items_changed = ''
    227227        # Remove application_number from row if empty
    228         if row.has_key('application_number') and row['application_number'] in (
     228        if 'application_number' in row and row['application_number'] in (
    229229            None, IGNORE_MARKER):
    230230            row.pop('application_number')
     
    232232        # Update applicant_id fom application_number and container code
    233233        # if application_number is given
    234         if row.has_key('application_number'):
     234        if 'application_number' in row:
    235235            obj.applicant_id = u'%s_%s' % (
    236236                row['container_code'], row['application_number'])
     
    239239
    240240        # Update password
    241         if row.has_key('password'):
     241        if 'password' in row:
    242242            passwd = row.get('password', IGNORE_MARKER)
    243243            if passwd not in ('', IGNORE_MARKER):
     
    252252
    253253        # Update registration state
    254         if row.has_key('state'):
     254        if 'state' in row:
    255255            state = row.get('state', IGNORE_MARKER)
    256256            if state not in (IGNORE_MARKER, ''):
     
    306306            if cert.application_category != parent.application_category:
    307307                errs.append(('course1', 'wrong application category'))
    308         if row.has_key('state') and \
     308        if 'state' in row and \
    309309            not row['state'] in IMPORTABLE_STATES:
    310310            if row['state'] not in (IGNORE_MARKER, ''):
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py

    r9531 r9701  
    169169    def delApplicantsContainers(self, **data):
    170170        form = self.request.form
    171         if form.has_key('val_id'):
     171        if 'val_id' in form:
    172172            child_id = form['val_id']
    173173        else:
     
    417417    def delApplicant(self, **data):
    418418        form = self.request.form
    419         if form.has_key('val_id'):
     419        if 'val_id' in form:
    420420            child_id = form['val_id']
    421421        else:
     
    442442    def createStudents(self, **data):
    443443        form = self.request.form
    444         if form.has_key('val_id'):
     444        if 'val_id' in form:
    445445            child_id = form['val_id']
    446446        else:
     
    849849    def delPaymentTickets(self, **data):
    850850        form = self.request.form
    851         if form.has_key('val_id'):
     851        if 'val_id' in form:
    852852            child_id = form['val_id']
    853853        else:
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py

    r9610 r9701  
    123123def delSubobjects(view, redirect, tab=None, subcontainer=None):
    124124    form = view.request.form
    125     if form.has_key('val_id'):
     125    if 'val_id' in form:
    126126        child_id = form['val_id']
    127127    else:
     
    242242            # has been set.
    243243            login = self.request.form['form.login']
    244             if len(login) == 8 and grok.getSite()['students'].has_key(login):
     244            if len(login) == 8 and login in grok.getSite()['students']:
    245245                student = grok.getSite()['students'][login]
    246246                password = self.request.form['form.password']
     
    841841    def delFiles(self, **data):
    842842        form = self.request.form
    843         if form.has_key('val_id'):
     843        if 'val_id' in form:
    844844            child_id = form['val_id']
    845845        else:
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/tests/test_browser.py

    r9326 r9701  
    316316        # former_course attribute of the corresponding course is set.
    317317        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    318         self.assertTrue(self.app['faculties']['fac1']['dep1'].certificates[
    319             'CERT1'].has_key('COURSE1_100'))
     318        self.assertTrue('COURSE1_100' in self.app[
     319            'faculties']['fac1']['dep1'].certificates['CERT1'])
    320320        self.browser.open(
    321321            'http://localhost/app/faculties/fac1/dep1/courses/COURSE1/manage')
    322322        self.browser.getControl(name="form.former_course").value = ['selected']
    323323        self.browser.getControl("Save").click()
    324         self.assertFalse(self.app['faculties']['fac1']['dep1'].certificates[
    325             'CERT1'].has_key('COURSE1_100'))
     324        self.assertFalse('COURSE1_100' in self.app[
     325            'faculties']['fac1']['dep1'].certificates['CERT1'])
    326326        return
    327327
     
    330330        # the corresponding course is removed.
    331331        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    332         self.assertTrue(self.app['faculties']['fac1']['dep1'].certificates[
    333             'CERT1'].has_key('COURSE1_100'))
     332        self.assertTrue('COURSE1_100' in self.app[
     333            'faculties']['fac1']['dep1'].certificates['CERT1'])
    334334        self.browser.open('http://localhost/app/faculties/fac1/dep1/manage')
    335335        ctrl = self.browser.getControl(name='val_id')
    336336        ctrl.getControl(value='COURSE1').selected = True
    337337        self.browser.getControl("Remove selected", index=0).click()
    338         self.assertFalse(self.app['faculties']['fac1']['dep1'].certificates[
    339             'CERT1'].has_key('COURSE1_100'))
    340         return
     338        self.assertFalse('COURSE1_100' in self.app[
     339            'faculties']['fac1']['dep1'].certificates['CERT1'])
     340        return
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/browser.py

    r9534 r9701  
    150150    def delHostels(self, **data):
    151151        form = self.request.form
    152         if form.has_key('val_id'):
     152        if 'val_id' in form:
    153153            deleted = []
    154154            child_id = form['val_id']
     
    285285    def switchReservations(self, **data):
    286286        form = self.request.form
    287         if form.has_key('val_id'):
     287        if 'val_id' in form:
    288288            child_id = form['val_id']
    289289        else:
     
    315315    def releaseBeds(self, **data):
    316316        form = self.request.form
    317         if form.has_key('val_id'):
     317        if 'val_id' in form:
    318318            child_id = form['val_id']
    319319        else:
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/hostel.py

    r9448 r9701  
    119119                        bt = u'%s_%s_%s' % (self.special_handling,sex,bt)
    120120                        uid = u'%s_%s_%d_%s' % (self.hostel_id,block,room_nr,bed)
    121                         if self.has_key(uid):
     121                        if uid in self:
    122122                            bed = self[uid]
    123123                            # Renumber remaining beds
  • main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py

    r9690 r9701  
    148148        # We have to log this if state is provided. If not,
    149149        # logging is done by the event handler handle_student_added
    150         if row.has_key('state'):
     150        if 'state' in row:
    151151            parent.logger.info('%s - Student record created' % obj.student_id)
    152152        history = IObjectHistory(obj)
     
    191191
    192192        # Remove student_id from row if empty
    193         if row.has_key('student_id') and row['student_id'] in (
    194             None, IGNORE_MARKER):
     193        if 'student_id' in row and row['student_id'] in (None, IGNORE_MARKER):
    195194            row.pop('student_id')
    196195
    197196        # Update password
    198         # XXX: Tale DELETION_MARKER into consideration
    199         if row.has_key('password'):
     197        # XXX: Take DELETION_MARKER into consideration
     198        if 'password' in row:
    200199            passwd = row.get('password', IGNORE_MARKER)
    201200            if passwd not in ('', IGNORE_MARKER):
     
    210209
    211210        # Update registration state
    212         if row.has_key('state'):
     211        if 'state' in row:
    213212            state = row.get('state', IGNORE_MARKER)
    214213            if state not in (IGNORE_MARKER, ''):
     
    221220            row.pop('state')
    222221
    223         if row.has_key('transition'):
     222        if 'transition' in row:
    224223            transition = row.get('transition', IGNORE_MARKER)
    225224            if transition not in (IGNORE_MARKER, ''):
     
    274273        errs, inv_errs, conv_dict =  converter.fromStringDict(
    275274            row, self.factory_name, mode=mode)
    276         if row.has_key('transition'):
     275        if 'transition' in row:
    277276            if row['transition'] not in IMPORTABLE_TRANSITIONS:
    278277                if row['transition'] not in (IGNORE_MARKER, ''):
    279278                    errs.append(('transition','not allowed'))
    280         if row.has_key('state'):
     279        if 'state' in row:
    281280            if row['state'] not in IMPORTABLE_STATES:
    282281                if row['state'] not in (IGNORE_MARKER, ''):
     
    438437            StudentStudyCourseProcessor, self).checkConversion(row, mode=mode)
    439438        # We have to check if current_level is in range of certificate.
    440         if conv_dict.has_key('certificate') and \
    441             conv_dict.has_key('current_level'):
     439        if 'certificate' in conv_dict and 'current_level' in conv_dict:
    442440            cert = conv_dict['certificate']
    443441            level = conv_dict['current_level']
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r9700 r9701  
    528528    def save(self, **data):
    529529        form = self.request.form
    530         if form.has_key('transition') and form['transition']:
     530        if 'transition' in form and form['transition']:
    531531            transition_id = form['transition']
    532532            wf_info = IWorkflowInfo(self.context)
     
    957957    def delStudyLevels(self, **data):
    958958        form = self.request.form
    959         if form.has_key('val_id'):
     959        if 'val_id' in form:
    960960            child_id = form['val_id']
    961961        else:
     
    11531153    def delCourseTicket(self, **data):
    11541154        form = self.request.form
    1155         if form.has_key('val_id'):
     1155        if 'val_id' in form:
    11561156            child_id = form['val_id']
    11571157        else:
     
    13531353    def delPaymentTicket(self, **data):
    13541354        form = self.request.form
    1355         if form.has_key('val_id'):
     1355        if 'val_id' in form:
    13561356            child_id = form['val_id']
    13571357        else:
     
    14061406        if 'maintenance' in p_category:
    14071407            current_session = str(student['studycourse'].current_session)
    1408             if not student['accommodation'].has_key(current_session):
     1408            if not current_session in student['accommodation']:
    14091409                self.flash(_('You have not yet booked accommodation.'))
    14101410                self.redirect(self.url(self.context))
     
    15591559            return
    15601560        form = self.request.form
    1561         if form.has_key('val_id'):
     1561        if 'val_id' in form:
    15621562            child_id = form['val_id']
    15631563        else:
     
    22162216    def _delCourseTicket(self, **data):
    22172217        form = self.request.form
    2218         if form.has_key('val_id'):
     2218        if 'val_id' in form:
    22192219            child_id = form['val_id']
    22202220        else:
  • main/waeup.kofa/trunk/src/waeup/kofa/university/batching.py

    r9333 r9701  
    9797        items_changed = ''
    9898
    99         if row.has_key('local_roles') and row['local_roles'] not in (
     99        if 'local_roles' in row and row['local_roles'] not in (
    100100            None, IGNORE_MARKER):
    101101            role_manager = IPrincipalRoleManager(obj)
     
    133133        errs, inv_errs, conv_dict =  super(
    134134            FacultyProcessor, self).checkConversion(row, mode=mode)
    135         if row.has_key('local_roles'):
     135        if 'local_roles' in row:
    136136            if row['local_roles'] in (None, DELETION_MARKER, IGNORE_MARKER):
    137137                return errs, inv_errs, conv_dict
Note: See TracChangeset for help on using the changeset viewer.