Changeset 6966 for main


Ignore:
Timestamp:
29 Oct 2011, 17:26:32 (13 years ago)
Author:
Henrik Bettermann
Message:

Catch KeyError?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/hostels/browser.py

    r6959 r6966  
    116116
    117117    # It's quite dangerous to remove entire hostels with its content (beds).
    118     # Thus, this removed should be combined with an archiving function.
     118    # Thus, this remove method should be combined with an archiving function.
    119119    @grok.action('Remove selected')
    120120    def delHostels(self, **data):
     
    123123            deleted = []
    124124            child_id = form['val_id']
    125             child_id = [child_id]
     125            if not isinstance(child_id, list):
     126                child_id = [child_id]
    126127            for id in child_id:
    127128                deleted.append(id)
     
    152153        self.applyData(hostel, **data)
    153154        hostel.hostel_id = data['hostel_name'].lower().replace(' ','_')
    154         self.context.addHostel(hostel)
     155        try:
     156            self.context.addHostel(hostel)
     157        except KeyError:
     158            self.flash('The hostel already exists.')
     159            return
    155160        self.flash('Hostel created.')
    156161        write_log_message(self, 'added: % s' % data['hostel_name'])
Note: See TracChangeset for help on using the changeset viewer.