On Friday, March 02, 2012 10:31:06 PM Dewald Jacobs wrote: > On Mar 2, 2012, at 10:22 PM, John Fabiani wrote: > > 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 > > No, but I see Paul did in the script he wrote. Was wondering if that could > be the solution. But I am not to sure how to implement it.
How about posting your code? Dabo attempts to create the required SQL statement when you add the bizobj class. You can check it by print bizobj.CurrentSQL. But you can always over ride the actual SQL statement used by using the many bizobj methods. UserSQL = "Select somefields from theTable where someField = someValue" or .setWhereClause "pkid = someValue" or .addJoin ("tableField = someOtherTableField", join='left') The syntax might be wrong -please check. But you get the idea. Dabo does not lock into only one way - the Dabo way. Nothing in Dabo should prevent you from succeeding when it comes to a database. 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/6977419.xz7NN0yP6X@linux-12