Hello again. I have this grid with 5 columns, works ok but when running
the form if I click on the column headers (to sort it) I get the
following exceptions (one click on every one of the 5 columns, so there
are 5 exceptions). The grid has Sortable=True as do the columns. I just
can't find out what I'm doing wrong.
-----------------------------------------------------------------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Python25\lib\site-packages\dabo\dabo\ui\uiwx\dGrid.py", line
3774, in
__onWxHeaderMouseLeftUp
self.raiseEvent(dEvents.GridHeaderMouseLeftUp, evt, col=col)
File "C:\Python25\lib\site-packages\dabo\dabo\ui\uiwx\dPemMixin.py",
line 949,
in raiseEvent
super(dPemMixin, self).raiseEvent(eventClass, nativeEvent, *args,
**kwargs)
File "C:\Python25\lib\site-packages\dabo\dabo\lib\eventMixin.py", line
93, in
raiseEvent
bindingFunction(event)
File "C:\Python25\lib\site-packages\dabo\dabo\ui\uiwx\dGrid.py", line
3288, in
_onGridHeaderMouseLeftUp
self.processSort(col)
File "C:\Python25\lib\site-packages\dabo\dabo\ui\uiwx\dGrid.py", line
2643, in
processSort
biz.sort(columnToSort, sortOrder, self.caseSensitiveSorting)
File "C:\Python25\lib\site-packages\dabo\dabo\biz\dBizobj.py", line
962, in so
rt
self._CurrentCursor.sort(col, ord, caseSensitive)
File "C:\Python25\lib\site-packages\dabo\dabo\db\dCursorMixin.py",
line 530, i
n sort
self.__sortRows(newCol, newOrd, caseSensitive)
File "C:\Python25\lib\site-packages\dabo\dabo\db\dCursorMixin.py",
line 555, i
n __sortRows
self.__unsortedRows.append(row[kf])
KeyError: 'PKId'
Traceback (most recent call last):
File "C:\Python25\lib\site-packages\dabo\dabo\ui\uiwx\dGrid.py", line
3774, in
__onWxHeaderMouseLeftUp
self.raiseEvent(dEvents.GridHeaderMouseLeftUp, evt, col=col)
File "C:\Python25\lib\site-packages\dabo\dabo\ui\uiwx\dPemMixin.py",
line 949,
in raiseEvent
super(dPemMixin, self).raiseEvent(eventClass, nativeEvent, *args,
**kwargs)
File "C:\Python25\lib\site-packages\dabo\dabo\lib\eventMixin.py", line
93, in
raiseEvent
bindingFunction(event)
File "C:\Python25\lib\site-packages\dabo\dabo\ui\uiwx\dGrid.py", line
3288, in
_onGridHeaderMouseLeftUp
self.processSort(col)
File "C:\Python25\lib\site-packages\dabo\dabo\ui\uiwx\dGrid.py", line
2643, in
processSort
biz.sort(columnToSort, sortOrder, self.caseSensitiveSorting)
File "C:\Python25\lib\site-packages\dabo\dabo\biz\dBizobj.py", line
962, in so
rt
self._CurrentCursor.sort(col, ord, caseSensitive)
File "C:\Python25\lib\site-packages\dabo\dabo\db\dCursorMixin.py",
line 530, i
n sort
self.__sortRows(newCol, newOrd, caseSensitive)
File "C:\Python25\lib\site-packages\dabo\dabo\db\dCursorMixin.py",
line 555, i
n __sortRows
self.__unsortedRows.append(row[kf])
KeyError: 'PKId'
Traceback (most recent call last):
File "C:\Python25\lib\site-packages\dabo\dabo\ui\uiwx\dGrid.py", line
3774, in
__onWxHeaderMouseLeftUp
self.raiseEvent(dEvents.GridHeaderMouseLeftUp, evt, col=col)
File "C:\Python25\lib\site-packages\dabo\dabo\ui\uiwx\dPemMixin.py",
line 949,
in raiseEvent
super(dPemMixin, self).raiseEvent(eventClass, nativeEvent, *args,
**kwargs)
File "C:\Python25\lib\site-packages\dabo\dabo\lib\eventMixin.py", line
93, in
raiseEvent
bindingFunction(event)
File "C:\Python25\lib\site-packages\dabo\dabo\ui\uiwx\dGrid.py", line
3288, in
_onGridHeaderMouseLeftUp
self.processSort(col)
File "C:\Python25\lib\site-packages\dabo\dabo\ui\uiwx\dGrid.py", line
2643, in
processSort
biz.sort(columnToSort, sortOrder, self.caseSensitiveSorting)
File "C:\Python25\lib\site-packages\dabo\dabo\biz\dBizobj.py", line
962, in so
rt
self._CurrentCursor.sort(col, ord, caseSensitive)
File "C:\Python25\lib\site-packages\dabo\dabo\db\dCursorMixin.py",
line 530, i
n sort
self.__sortRows(newCol, newOrd, caseSensitive)
File "C:\Python25\lib\site-packages\dabo\dabo\db\dCursorMixin.py",
line 555, i
n __sortRows
self.__unsortedRows.append(row[kf])
KeyError: 'PKId'
Traceback (most recent call last):
File "C:\Python25\lib\site-packages\dabo\dabo\ui\uiwx\dGrid.py", line
3774, in
__onWxHeaderMouseLeftUp
self.raiseEvent(dEvents.GridHeaderMouseLeftUp, evt, col=col)
File "C:\Python25\lib\site-packages\dabo\dabo\ui\uiwx\dPemMixin.py",
line 949,
in raiseEvent
super(dPemMixin, self).raiseEvent(eventClass, nativeEvent, *args,
**kwargs)
File "C:\Python25\lib\site-packages\dabo\dabo\lib\eventMixin.py", line
93, in
raiseEvent
bindingFunction(event)
File "C:\Python25\lib\site-packages\dabo\dabo\ui\uiwx\dGrid.py", line
3288, in
_onGridHeaderMouseLeftUp
self.processSort(col)
File "C:\Python25\lib\site-packages\dabo\dabo\ui\uiwx\dGrid.py", line
2643, in
processSort
biz.sort(columnToSort, sortOrder, self.caseSensitiveSorting)
File "C:\Python25\lib\site-packages\dabo\dabo\biz\dBizobj.py", line
962, in so
rt
self._CurrentCursor.sort(col, ord, caseSensitive)
File "C:\Python25\lib\site-packages\dabo\dabo\db\dCursorMixin.py",
line 530, i
n sort
self.__sortRows(newCol, newOrd, caseSensitive)
File "C:\Python25\lib\site-packages\dabo\dabo\db\dCursorMixin.py",
line 555, i
n __sortRows
self.__unsortedRows.append(row[kf])
KeyError: 'PKId'
Traceback (most recent call last):
File "C:\Python25\lib\site-packages\dabo\dabo\ui\uiwx\dGrid.py", line
3774, in
__onWxHeaderMouseLeftUp
self.raiseEvent(dEvents.GridHeaderMouseLeftUp, evt, col=col)
File "C:\Python25\lib\site-packages\dabo\dabo\ui\uiwx\dPemMixin.py",
line 949,
in raiseEvent
super(dPemMixin, self).raiseEvent(eventClass, nativeEvent, *args,
**kwargs)
File "C:\Python25\lib\site-packages\dabo\dabo\lib\eventMixin.py", line
93, in
raiseEvent
bindingFunction(event)
File "C:\Python25\lib\site-packages\dabo\dabo\ui\uiwx\dGrid.py", line
3288, in
_onGridHeaderMouseLeftUp
self.processSort(col)
File "C:\Python25\lib\site-packages\dabo\dabo\ui\uiwx\dGrid.py", line
2643, in
processSort
biz.sort(columnToSort, sortOrder, self.caseSensitiveSorting)
File "C:\Python25\lib\site-packages\dabo\dabo\biz\dBizobj.py", line
962, in so
rt
self._CurrentCursor.sort(col, ord, caseSensitive)
File "C:\Python25\lib\site-packages\dabo\dabo\db\dCursorMixin.py",
line 530, i
n sort
self.__sortRows(newCol, newOrd, caseSensitive)
File "C:\Python25\lib\site-packages\dabo\dabo\db\dCursorMixin.py",
line 555, i
n __sortRows
self.__unsortedRows.append(row[kf])
KeyError: 'PKId'
-----------------------------------------------------------------------------------------------------------------------------
Ricardo ArÃÆÃ¡oz wrote:
> Hello again. I have this grid with 5 columns, works ok but when running
> the form if I click on the column headers (to sort it) I get the
> following exceptions (one click on every one of the 5 columns, so there
> are 5 exceptions). The grid has Sortable=True as do the columns. I just
> can't find out what I'm doing wrong.
> File "C:\Python25\lib\site-packages\dabo\dabo\db\dCursorMixin.py",
> line 555, i
> n __sortRows
> self.__unsortedRows.append(row[kf])
> KeyError: 'PKId'
You have biz.KeyField set to "PKId". Does that field exist in the table, with that
same case-sensitive capitalization? To find out, open a command window from your app
(Ctrl+D) and issue:
biz = self.getBizobj("<the_bizobj's_datasource>")
pkfields = [f[0] for f in self.DataStructure if f[2]]
print pkfields
print biz.KeyField
print biz.KeyField == pkfields[0]
Paul
Paul McNett wrote:
> Ricardo ArÃÆÃ¡oz wrote:
>
>> Hello again. I have this grid with 5 columns, works ok but when running
>> the form if I click on the column headers (to sort it) I get the
>> following exceptions (one click on every one of the 5 columns, so there
>> are 5 exceptions). The grid has Sortable=True as do the columns. I just
>> can't find out what I'm doing wrong.
>>
>
>
>> File "C:\Python25\lib\site-packages\dabo\dabo\db\dCursorMixin.py",
>> line 555, i
>> n __sortRows
>> self.__unsortedRows.append(row[kf])
>> KeyError: 'PKId'
>>
>
> You have biz.KeyField set to "PKId". Does that field exist in the table, with that
> same case-sensitive capitalization? To find out, open a command window from your app
> (Ctrl+D) and issue:
>
> biz = self.getBizobj("<the_bizobj's_datasource>")
> pkfields = [f[0] for f in self.DataStructure if f[2]]
> print pkfields
> print biz.KeyField
> print biz.KeyField == pkfields[0]
>
Second line raised : AttributeError: 'dForm_30698' object has no
attribute 'DataStructure'
So I swapped "biz" for "self".
The results were :
------------------------------------------------
[]
PKId
Traceback (most recent call last):
File "<input>", line 1, in <module>
IndexError: list index out of range
------------------------------------------------
My bizobj :
class OpMejoraBizobj(dabo.biz.dBizobj):
def afterInit(self):
self.DataSource = "OpMejora"
self.KeyField = "PKId"
self.addFrom("OpMejora")
self.addField("Registro")
self.addField("Revision")
self.addField("FechaOrigen")
etc....
My table :
CREATE TABLE opmejora (
"PKId" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"Registro" INTEGER,
"Revision" INTEGER,
"FechaOrigen" TEXT,
"FKSectorOrigen" INTEGER,
"FKClasificacion" INTEGER,
etc...
So it would seem ok.
Though it worries me the fact that I have not defined a DataStructure in
the bizobj, I thought it was not necessary.
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
Ricardo ArÃÆÃ¡oz wrote:
> Paul McNett wrote:
>> Ricardo ArÃÆÃ¡oz wrote:
>>
>>> Hello again. I have this grid with 5 columns, works ok but when running
>>> the form if I click on the column headers (to sort it) I get the
>>> following exceptions (one click on every one of the 5 columns, so there
>>> are 5 exceptions). The grid has Sortable=True as do the columns. I just
>>> can't find out what I'm doing wrong.
>>>
>>
>>> File "C:\Python25\lib\site-packages\dabo\dabo\db\dCursorMixin.py",
>>> line 555, i
>>> n __sortRows
>>> self.__unsortedRows.append(row[kf])
>>> KeyError: 'PKId'
>>>
>> You have biz.KeyField set to "PKId". Does that field exist in the table, with that
>> same case-sensitive capitalization? To find out, open a command window from your app
>> (Ctrl+D) and issue:
>>
>> biz = self.getBizobj("<the_bizobj's_datasource>")
>> pkfields = [f[0] for f in self.DataStructure if f[2]]
>> print pkfields
>> print biz.KeyField
>> print biz.KeyField == pkfields[0]
>>
> Second line raised : AttributeError: 'dForm_30698' object has no
> attribute 'DataStructure'
> So I swapped "biz" for "self".
Oops, my bad. :)
> The results were :
> ------------------------------------------------
> []
No pk field found in the DataStructure. What does this give:
print [f[0] for f in self.DataStructure]
Either your pk field isn't being selected as one of the fields, or dabo isn't
identifying the keyfield properly).
> PKId
> Traceback (most recent call last):
> File "<input>", line 1, in <module>
> IndexError: list index out of range
> ------------------------------------------------
> My bizobj :
> class OpMejoraBizobj(dabo.biz.dBizobj):
> def afterInit(self):
> self.DataSource = "OpMejora"
> self.KeyField = "PKId"
> self.addFrom("OpMejora")
> self.addField("Registro")
> self.addField("Revision")
> self.addField("FechaOrigen")
> etc....
Do you have anywhere:
self.addField("PKId")
?
> My table :
> CREATE TABLE opmejora (
> "PKId" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
> "Registro" INTEGER,
> "Revision" INTEGER,
> "FechaOrigen" TEXT,
> "FKSectorOrigen" INTEGER,
> "FKClasificacion" INTEGER,
> etc...
>
> So it would seem ok.
> Though it worries me the fact that I have not defined a DataStructure in
> the bizobj, I thought it was not necessary.
It isn't necessary to explicitly define the DataStructure. Whether you let dabo set
DataStructure automatically, or you set it yourself, DataStructure will be defined.
My practice is to *always* define DataStructure explicitly, because sometimes Dabo's
implicitness causes hard-to-diagnose problems.
Paul
Paul McNett wrote:
>
> Do you have anywhere:
> self.addField("PKId")
> ?
>
>
That was it! Didn't know I had to add the KeyField. Thanks a lot.
> It isn't necessary to explicitly define the DataStructure. Whether you let dabo set
> DataStructure automatically, or you set it yourself, DataStructure will be defined.
>
> My practice is to *always* define DataStructure explicitly, because sometimes Dabo's
> implicitness causes hard-to-diagnose problems.
>
Good to know! Will do. Thanks a lot Paul.
Ricardo
Ricardo ArÃÆÃ¡oz wrote:
> Paul McNett wrote:
>> Do you have anywhere:
>> self.addField("PKId")
>> ?
>>
>>
> That was it! Didn't know I had to add the KeyField. Thanks a lot.
I guess Dabo could do that easily enough, if it wasn't added explicitly. Might be a
nice addition.
Paul
On Sep 9, 2009, at 8:40 PM, Paul McNett wrote:
> I guess Dabo could do that easily enough, if it wasn't added
> explicitly. Might be a
> nice addition.
Is this a DataNav app? Adding the PK field is done automatically when
you add controls using the data environment wizard.
-- Ed Leafe
Ed Leafe wrote:
> On Sep 9, 2009, at 8:40 PM, Paul McNett wrote:
>
>
>> I guess Dabo could do that easily enough, if it wasn't added
>> explicitly. Might be a
>> nice addition.
>>
>
> Is this a DataNav app? Adding the PK field is done automatically when
> you add controls using the data environment wizard.
>
>
No, it is not. Created the form with the Class Designer but wrote the
bizobj myself. I copied the bizobj from a form with controls added via
the data environment wizard, so that's why I didn't have the primary key
added as a field.
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
Ricardo ArÃÆÃ¡oz wrote:
> Ed Leafe wrote:
>> On Sep 9, 2009, at 8:40 PM, Paul McNett wrote:
>>
>>
>>> I guess Dabo could do that easily enough, if it wasn't added
>>> explicitly. Might be a
>>> nice addition.
>>>
>> Is this a DataNav app? Adding the PK field is done automatically when
>> you add controls using the data environment wizard.
>>
>>
> No, it is not. Created the form with the Class Designer but wrote the
> bizobj myself. I copied the bizobj from a form with controls added via
> the data environment wizard, so that's why I didn't have the primary key
> added as a field.
I was thinking that at the time of requery, if biz.KeyField isn't present in the sql
fields clause, we could add it automatically.
Paul
On Sep 9, 2009, at 10:30 PM, Paul McNett wrote:
> I was thinking that at the time of requery, if biz.KeyField isn't
> present in the sql
> fields clause, we could add it automatically.
We could, but that would be a little draconian, don't ya think? After
all, our 'users' are developers, and should know that in any client/
server design, PKs are essential to working with server-side data.
-- Ed Leafe