How are you calling fetchText? Are you sure the value you are passing as the 'name' argument is in fact the value of the 'hash' field of one of the records?
On Tuesday, October 18, 2011 12:16:09 PM UTC-4, Sathvik Ponangi wrote: > > Dear Johann, > I'm using Web2py with Google AppEngine & I can see that the rows have the > required value on the DataStore Viewer (on the SDK console). Here is the > snippet I'm using: > > def fetchText(name): > > textobj = db(db.files.hash==name).select().last() > > if not textobj: > > textobj_id = db.files.insert(hash=name, name=name, path=name, text="") > > textobj = db.files[textobj_id] > > > Thank you for your attention. > > With Regards, > Sathvik > > > > On Tue, Oct 18, 2011 at 5:29 PM, Johann Spies <johann...@gmail.com> wrote: > >> On 18 October 2011 13:20, Sathvik Ponangi <psat...@gmail.com> wrote: >> >>> db(db.files.hash==name).select().first() always gives None, what's the >>> right way to do it? >>> >>> Thanks for your help... >>> >> >> .first() will only work if len(db(db.files.hash==name).select()) > 0 >> >> If you get None it means that the query did not find anything. If the >> query find something the length of the result will be >=1 >> >> Regards >> Johann >> >> -- >> Because experiencing your loyal love is better than life itself, >> my lips will praise you. (Psalm 63:3) >> >> > > > -- > Sathvik Ponangi >