Re: [dabo-users] Grid from SQLite Views

Author: John Fabiani

Posted: 2012-03-02 at 14:22:17

On Friday, March 02, 2012 10:12:55 PM Dewald Jacobs wrote:

> On Mar 2, 2012, at 9:04 PM, Paul McNett wrote:

> > On 3/2/12 10:55 AM, Paul McNett wrote:

> >> When confronted by things like this, I like to reduce them down with

> >> as few variables as possible, in a single, simple script. Please look

> >> at this script and run it, which seems to prove that there isn't

> >> anything obviously wrong at the Dabo layer, although you should tweak

> >> the script to better match your situation, like adding the second

> >> table, etc.:

> >>

> >> http://paulmcnett.com/test_sqlite_view.py

> >

> > Oh, hang on... a click on a grid header results in the traceback:

> >

> > {{{

> >

> > Traceback (most recent call last):

> > File "/home/pmcnett/dabo-full/trunk/dabo/ui/uiwx/dGrid.py", line

> > 4161, in>

> > __onWxHeaderMouseLeftUp

> >

> > self.raiseEvent(dEvents.GridHeaderMouseLeftUp, evt, col=col)

> >

> > File "/home/pmcnett/dabo-full/trunk/dabo/ui/uiwx/dPemMixin.py", line

> > 1074, in>

> > raiseEvent

> >

> > super(dPemMixin, self).raiseEvent(eventClass, nativeEvent,

> > *args, **kwargs)>

> > File "/home/pmcnett/dabo-full/trunk/dabo/lib/eventMixin.py", line

> > 81, in raiseEvent>

> > bindingFunction(event)

> >

> > File "/home/pmcnett/dabo-full/trunk/dabo/ui/uiwx/dGrid.py", line

> > 3632, in>

> > _onGridHeaderMouseLeftUp

> >

> > self.processSort(col)

> >

> > File "/home/pmcnett/dabo-full/trunk/dabo/ui/uiwx/dGrid.py", line

> > 2894, in processSort>

> > biz.sort(columnToSort, sortOrder, self.caseSensitiveSorting)

> >

> > File "/home/pmcnett/dabo-full/trunk/dabo/biz/dBizobj.py", line 1209,

> > in sort>

> > cc.sort(col, ordr, caseSensitive)

> >

> > File "/home/pmcnett/dabo-full/trunk/dabo/db/dCursorMixin.py", line

> > 593, in sort>

> > self.__sortRows(newCol, newOrd, caseSensitive)

> >

> > File "/home/pmcnett/dabo-full/trunk/dabo/db/dCursorMixin.py", line

> > 619, in __sortRows>

> > self.__unsortedRows.append(row[kf])

> >

> > KeyError: u'id'

> > }}}

> >

> > I messed up writing the script and had the KeyField defined in the

> > bizobj as "id" and not "Id". Making that change makes grid sorting work

> > just fine, as well as probably everything else that relies on KeyField.

> > I've fixed the test script online:

> >

> > http://paulmcnett.com/test_sqlite_view.py

> >

> > Paul

>

> The script ran perfectly. So in theory the view should also work in my

> example. The only unknown left (that I can think of) might be some rookie

> mistake on my part or the classdesigner as John pointed out.

>

> I have now simplified my app (also, only using lowercase for column and

> table/view names) and I now only have the following traceback that cycles

> for all columns:

>

> Traceback (most recent call last):

> File "C:\projects\dabo\ui\uiwx\dGrid.py", line 331, in GetValue

> ret = self.getStringValue(bizobj.getFieldVal(field, row))

> File "C:\projects\dabo\biz\dBizobj.py", line 1872, in getFieldVal

> ret = self._CurrentCursor.getFieldVal(fld, row,

> _rowChangeCallback=changeRow NumCallback)

> File "C:\projects\dabo\db\dCursorMixin.py", line 940, in getFieldVal

> _("Field"), fld, _("does not exist in the data set")))

> dabo.dException.FieldNotFoundException: Field 'idnommer' does not exist in

> the d ata set

>

> The one line in the script that stands out to me is this:

>

> cur.UserSQL = "select Id, FirstName from v_test"

>

> Might this be the property that I am missing?

You are setting your own SQL?

How about posting the code

http://dabo.codepad.org/\

Johnf

_______________________________________________

Post Messages to: Dabo-users@leafe.com

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/2371180.b4u5AzpSKF@linux-12

©2012 John Fabiani