class QChoicesAtom(QAtom):
"""This class represents a query for an attribute with a discrete fixed
   set of choices.
"""
def __init__(self, **kwargs):
    QAtom.__init__(self, **kwargs)
    
    # group all the search terms into one string
    searchString = " ".join(self.search)
    
    # if it's a numeric choice, then spit back the number
    if searchString[0] in "1234556789":
        search = int(search)
    
    # if it's not numeric, test the choices until one matches
    # and return its index
    else:
        for i, choice in enumerate(choicesDict[self.attribute]):
            if choice.match(searchString):
                search = i
                break
    
    # we should have assigned the search to a number, based on it either
    # being a number, or one of the listed choices.  Otherwise, raise
    # an exception.
    try:
        self.search = search
    except NameError:
        raise ValueError(
            "search not among defined choices for attribute")
        

def rawQuery(self):
    
    if self.operator == "exact":
        operator = (self.negative and " != " or " == ")
    else:
        raise ValueError(
            "operator makes no sense for type/creator code query")
        
    return self.attribute + operator + str(self.search)