durusmail: quixote-users: form2 Form.has_key
form2 Form.has_key
form2 Form.has_key
Roger E. Masse
2004-01-04
Christoph Devenoges writes:

 > is there any reason why the form2 Form (0.7a3) class doesnt implement the
 > has_key method? There is after all a __getitem__?
 >
 >
 > this allows stuff like:
 > bookings = form.has_key('apartment') and form['apartment'].bookings \
 >            or \
 >         form.has_key('customer') and form['customer'].bookings or []

Another alternative is to use get:

        bookings = form.get('apartment') or []

Regards,

    Roger E. Masse - Software Engineer 
    MEMS Exchange - Corporation for National Research Initiatives
    1895 Preston White Drive Suite 100, Reston Virginia USA 20191


reply