On Thursday 25 September 2008 06:43:09 am Sibylle Koczian wrote:
> Am Mittwoch, 24. September 2008 21:37:16 schrieb Ed Leafe:
> > On Sep 24, 2008, at 12:22 PM, Paul McNett wrote:
> > > And I'll reiterate again that I do this all the time, by using
> > > biz.DefaultValues["pk"] = myFunc. It works without any special
> > > workaround.
> >
> >     But if you were to change the PK between that initial assignment and
> > saving, it would not work. That's the difference between your system
> > and Sibylle's: since your PK is assigned early, it appears in the
> > cursor's _newRecords dict. Sybylle defaults to no value, so None gets
> > stored in _newRecords. Later when the record is being saved, the
> > manually-changed PK is checked against _newRecords, and it is not
> > found. So Dabo treats it as an update instead of an insert, and we get
> > the bug that was observed.
>
> I'm trying to find a way to assign my PK early on. My first attempt wasn't
> successful, but I think I know why: I called biz.setFieldVal() in the
> beforeNew() method, but at this point my entry field wasn't yet filled in.
>
> It sounds a little crazy, but I suppose I might set biz.DefaultValues["pk"]
> from the UI (the UI must know about the bizobj anyway, only not the other
> way around). Will try it out and report here.
>
> Greetings,
> Sibylle

This may sound crazy but how about turning it around.  Allow Dabo to create 
the PK (using the internal auto increment stuff).  Then in your form over 
ride the save() and in there change the PK at the very last moment.

def save(self):
  change the pk
  self.super()

I think that's how I handled the problem in the past.  However, maybe the 
framework code has changed so much that it will no longer allow the late 
setting.
-- 
John Fabiani


_______________________________________________
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