Hello everyone. I'm trying to figure out how to better do something
that I've currently got...

I've got a member's table in my database... It currently has a number
of boolcol fields:

class Member(SQLObject):
    username = StringCol(length=25, alternateID=True)
    appearance_0 = BoolCol(default=False)
    appearance_1 = BoolCol(default=False)
    appearance_2 = BoolCol(default=False)
    appearance_3 = BoolCol(default=False)

    ....

I've got a whole load of that type of definition (matching service, if
you don't know already)... I've got them set up like that because I'm
using checkboxes for the user to select as many items as they so
please, and I'd like to allow a user to search for members with an OR
style search:

        where appearance_0 is true, appearance_1 is false, appearance_2
is true, etc

The nicest solution for this would be if I could search through the
database with something like:

        app = userselectedpreferences
        Member.select(appearance contains app)

As it is right now, I get a nice little list back from the checkboxes
on my form, and I have to go through it manually:

        if 0 in thelist: appearance_0 = True
        if 1 in thelist: appearance_1 = True
        if 2 in thelist: appearance_2 = True

It's a pain, to say the least, and if I have to add or remove an item
from the list, it could give me some big headaches.

I'm leaving this very vague, because I'd like to know how others have
approached problems such as this one (but not necessarily the exact
same thing)... Sorry if I haven't explained enough of it, I'll provide
further details if needed.. I also figure that since I'm really quite a
novice with programming in python, there's probably a very elegant
solution available that I just don't know how to find.

Thanks everyone!

_________________________________
http://kassemi.blogspot.com

Reply via email to