Ed Leafe wrote:
> On Oct 3, 2009, at 12:04 AM, Ricardo Aráoz wrote:
>
>   
>> Right, so I have the following in my dDialog (funny was that there  
>> is no
>> builtin property .PrimaryBizobj)  :
>>     
>
>       It's not funny; it's deliberate. Forms are designed for data editing;  
> dialogs are supposed to be for brief notifications to the user. It's  
> consistent with the philosophy that modal states are to be avoided,  
> not encouraged.
>   
In this particular case the dialog is not for user notification but to
get a set of filters from the user, and it MUST be a dialog, the user
has just expressed his will to filter some data (by clicking a filter
button) and I want him to either give me the filter before doing
anything else with the originating form or cancel the whole filter
operation.

>> 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' ?
>>     
>
>       First, you should always be aware of the following: when it feels as  
> though you're fighting the framework, or re-implementing a big chunk  
> of it to get around something, that's a sign that you are  
> misunderstanding or misusing the framework.
>   
Yes, probably. Had a feeling I was going the wrong way but couldn't
think of a better path.

>       Why do you need a bizobj? I thought that this data was display-only,  
> and not going to be persisted. If that's the case, then why bother  
> with sqlite, bizobjs, cursors, etc., and just create the data as you  
> mentioned in your original post? Then you'll have a dataset, and can  
> set the grid's DataSouce to that dataset. In fact, you could do  
> something like this:
>
> ds = ({...}, {...})
> grid = dabo.ui.dGrid(self, ...)
> grid.buildFromDataSet(ds)
>   
What drove me to the bizobj thing was that I needed the ds to be empty
for starters, so that would be just an empty tuple and didn't feel
right. Besides I would be more comfortable issuing bzob.save() and
bzob.new().
Anyway I tried and I found that :
-------------------------------------------------------------------
>>> ds = dabo.db.dDataSet(({'fld1':1, 'fld2':'uno'},))
>>> ds
({'fld2': 'uno', 'fld1': 1},)
>>> ds = ds.execute("insert into dataset (fld1, fld2) values (2, 'dos')")
>>> ds
({'fld2': u'uno', 'fld1': 1}, {'fld2': u'dos', 'fld1': 2})
--------------------------------------------------------------------
worked as I expected. But if I wanted to start with an empty dataset
(which is my use case)
---------------------------------------------------------------------
>>> ds = dabo.db.dDataSet()
>>> ds
()
>>> ds = ds.execute("insert into dataset (fld1, fld2) values (1, 'uno')")
>>> print ds
None
---------------------------------------------------------------------
Which is to be expected if you think the dataset has no fields defined,
but it's not what I need. Couldn't find out how to define the fields of
the dataset without actually adding a row, tried doing ds.execute() with
a create instruction but without success. So I would have to consider an
empty dataset as a special case and I didn't like that in my code. So
bizobjs seemed reasonable and the natural way to go with a grid, and if
I had a way to give the grid a proper DataSource it would have gone
smoothly.

>       Check out the code in the dabo.ui.ui.uiwx.__init__.py.browse() method.
>   
I'll check it later and see if I come up with something.

Thanks Ed.



--- 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