Hi,
need help we a maybe newbie question.
i'm using cherrypy and sqlobject to write a litte program.
actually i'm implementing the search pages and i would like to use
automatically the startswith option every time the column type is
"String".
i will pass 1...n parameters and the i evaluate and split them into
column-name and search value.
i have the column-name and need to know the filed type of this column

here my "working" example where i'm actually checking the name instead
of the column type.

thx mike

[...]
class Webuser(SQLObject):
        _connection = myconn
        username = StringCol(length = 15)
        group = IntCol()

[....]
def mysearchresult(self, **kwargs):
        if len(kwargs) > 0:
                evalList = []
                for kw in kwargs.items():
                        #assemble all criteria into a bigstring
                        #to be evaluated
                        key, val = kw
                        if key == "username":
                                evalList.append('Webuser.q.%s.startswith("%s")'
% (key, val))
                        else:                                           
                                evalList.append('Webuser.q.%s=="%s"' %
(key, val))
                        
                        if len(kwargs) == 1:
                                critString = ''.join(evalList)
                                evalString = 'Webuser.select(%s)' %
(critString)
                                mywebusers = eval(evalString)
                        else:
                                critString = ' , '.join(evalList)
                                evalString = 'Webuser.select(AND(%s))'
% (critString)
                                mywebusers = eval(evalString)
                else:
                        mywebusers = Webuser.select()
                
                template = Template('''
                        [..]
        

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to