[Zope] Qurying a TinyTable (plus)

Mark Gibson mark at kaivo.com
Wed May 5 13:46:20 EDT 2004


Philip Kilner wrote:
> Hi Mark,
> 
> Mark Gibson wrote:
> 
>>> Can anyone give me a clue, or point to a fuller example than those in 
>>> the TinyTable docs please?
>>
>>
>> Say you have:
>>
>> TinyTable : mytable
>> Columns : mykey  myvalue
>> mykey    myvalue
>> ---------------
>> "1"    "One"
>> "2"    "Two"
>>
>> Then:
>>
>> value1 = mytable(mykey="1")[0]['myvalue']
>> value1 = mytable(mykey="2")[0]['myvalue']

> My only problem is that I don't /really/ understand how it works! 
> Clearly, process_spec(step='1') is referring to the index of my 
> TinyTable. But the significance of [0] and the way in which 
> ['form_name'] seems to be "outside" the clause are confusing the hell 
> out of me!
> 
> Anyone kind enough to clue me in?

mytable() querys the tt and returns a list of dictionaries ( or at 
least something that implements a dictionary interface).  Any query to 
the tt will return a list of dictionaries.

So for the above example:
mytable() will return all the rows in the tt:
[ { "mykey":"1", "myvalue":"One" },
   { "mykey":"2", "myvalue":"Two" } ]

Given this, mytable(mykey="1") will return:
  [ {"mykey":"1", "myvalue":"One"},  ]

 From there, you should be able to figure out what the rest of it does.

Mark





More information about the Zope mailing list