Denes,

> The auto-complete part was not mentioned in this thread but it should
> be OK as per your logic, except for the extreme case where the
> selected postcoderegio is deleted while the form is being shown.

I guess it is best to take this extreme case into account, the code
now reads:


if form.accepts(request.vars,session):
        minmax=db
(db.postcoderegio.regio==request.vars.postcoderegio).select
(db.postcoderegio.codemin,db.postcoderegio.codemax)
        if minmax:
            minimum=int(minmax[0].codemin)
            maximum=int(minmax[0].codemax)
            clubs=db((db.bedrijf.id==db.adres.bedrijf)&
(db.bedrijf.id==db.bedrijfinschrijving.bedrijf)&\
            (db.adres.postcode_cijferdeel>=minimum)&
(db.adres.postcode_cijferdeel<=maximum)\
            &(db.adres.adressoort=='vestigingsadres')&
(db.bedrijfinschrijving.inschrijving=='fitnessclub'))\
            .select
(db.bedrijf.id,db.bedrijf.bedrijfsnaam,db.bedrijf.status,db.adres.straat,
\
            db.adres.plaats,orderby=db.bedrijf.status|
db.bedrijf.bedrijfsnaam)
        else:
            response.flash='Please provide a valid postal code'
            clubs=[]


> In Python the following are considered to be False:
> 1) None
> 2) False
> 3) zero of any numeric type, for example, 0, 0L, 0.0, 0j
> 4) any empty sequence, for example, '', (), []
> 5) any empty mapping, for example, {}
> 6) instances of user-defined classes, if the class defines a
> __nonzero__() or __len__() method, when that method returns the
> integer zero or bool value False
>
> so you could check minmax's "emptyness" using:
> if minmax:
>   # it is not empty
> else:
>   # it is empty (see 4 above)

Thanks I added this to my log.


> but your code using len() is fine too.

But not as beautiful as:
    if minmax: ...
    else: ...


Best regards,

Annet.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to