Paul McNett wrote:
> Ed Leafe wrote:
>   
>> On Oct 2, 2009, at 6:46 PM, Ricardo Aráoz wrote:
>>
>>     
>>> I can see that ds = dabo.db.dDataSet() returns a dataset object, but I
>>> wasn't able to find out how to define it's structure and generally  
>>> work
>>> with it.
>>>       
>>      A dabo.db.dDataSet is simply a subclass of tuple. A record is best  
>> represented as a Python dict, with column names as keys and values as  
>> the, well, values. A set of records is a tuple of these dicts, where  
>> every record has the same keys and same data types for each key value.  
>> The dDataSet class wraps that with some additional capabilities.
>>
>>      To create one, it's pretty straightforward: create a tuple (or even a  
>> list) of dicts, and pass that to the dDataSet constructor. E.g.:
>>
>> recs = ({"foo": 1, "bar": "something"},
>>              {"foo": 2, "bar": "else"})
>> ds = dabo.db.dDataSet(recs)
>>     
>
> You could also go ahead and create a sqlite table on an in-memory database.
>
> {{{
> import dabo
> con = dabo.db.connect(dbType="sqlite", Database=":memory:")
> cur = con.cursor()
> cur.execute("create table test (field1 char, field2 int)")
> cur.execute("insert into test (field1, field2) values ('test', 1)")
> }}}
>
> And you could even make a bizobj off of it (to ease data binding):
>
> {{{
> biz = dabo.biz.dBizobj(con, Datasource="test", KeyField="field2", ...)
> biz.requery()
> }}}
>   
Right, so I have the following in my dDialog (funny was that there is no
builtin property .PrimaryBizobj)  :
-----------------------------------------------------------------------
def afterInit(self):
    self.Aceptar = 'No aceptado'
    self.conn = dabo.db.connect(dbType="sqlite", Database=":memory:")
    self.crsr = conn.cursor()
    self.crsr.execute("""create table Filtro
                                        ('PKId' INTEGER PRIMARY KEY
AUTOINCREMENT NOT NULL
                                        ,'campo' TEXT
                                        , operador TEXT
                                        , valor TEXT)""")
    #self.crsr.execute("insert into test (field1, field2) values
('test', 1)")
   
    self.PrimaryBizobj = dabo.biz.dBizobj(self.conn)
    self.PrimaryBizobj.Datasource = 'Filtro'
    self.PrimaryBizobj.KeyField = 'PKId'
    self.PrimaryBizobj.AutoPopulatePK = True
    self.PrimaryBizobj.DataStructure = (('PKId', 'I', True,
'Filtro','PKId', None)
                                                                    ,
('campo', 'C', False, 'Filtro', 'campo', None)
                                                                    ,
('operador', 'C', False, 'Filtro', 'operador', None)
                                                                    ,
('valor', 'C', False, 'Filtro', 'valor', None))

----------------------------------------------------------------------------------------------------
Now what do I put in dGrid.DataSource? My form (dDialog) has no
"matching DataSource" that I know of (I have the feeling I'm doing
something really wrong here). Should it be just dGrid.DataSource =
'Filtro' ?




--- StripMime Report -- processed MIME parts ---
multipart/alternative
  text/plain (text body -- kept)
  text/html
---

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]

Reply via email to