Thank you.
By the way: Ach!
def dumb_oversight():
bang_head_on_desk
On Sep 22, 9:22 am, Massimiliano <[email protected]> wrote:
> maybe:
> len(supplier_contact_list)==1
>
>
>
>
>
> On Thu, Sep 22, 2011 at 3:15 PM, Cliff <[email protected]> wrote:
> > Is this the way it's supposed to work, or have I created a subtle bug?
>
> > Here is the code snippet:
>
> > supplier_contact_list = db(db.supplier_contacts.supplier_id==
> > supplier_id).select(
> > db.supplier_contacts.first_name,
> > db.supplier_contacts.middle_name,
> > db.supplier_contacts.last_name,
> > db.supplier_contacts.generation)
> > print db._lastsql
> > if not supplier_contact_list:
> > contact_string = 'This supplier has no contact.'
> > elif len(supplier_contact_list==1): ## Exception gets raised on
> > this line
> > ## do stuff
>
> > It raises this exception:
> > TypeError: object of type 'bool' has no len()
>
> > Here is the SQL that rockit prints:
> > SELECT supplier_contacts.first_name, supplier_contacts.middle_name,
> > supplier_contacts.last_name, supplier_contacts.generation FROM
> > supplier_contacts WHERE (supplier_contacts.supplier_id = 1);
>
> > I can work around this using db().count(), but it's an extra database
> > hit and makes the code verbose.
>
> --
> Massimiliano