On Dec 29, 2009, at 11:12 PM, Carey Gagnon wrote:

> As the MySQL auto increment number is used as a number that gets put on
> accompanying paper work I would like to extend the message to include the
> last inserted ID.
> I read this thread on *getLastInsertID   *
> http://old.nabble.com/form.cancel-on-a-PageFrame-form-td10014107.html#a10019778
> *   *but can wrap my head around getting it in the info dialog so I get
> something like:*
> 
> *def afterSave(self):
>    # This will only get called if the save succeeds
>    dabo.ui.info("Record successfully saved. Your new number is DC10- ID OF
> LAST INSERTED RECORD HERE ", title="Success")
>    self.new()
>    self.BuilderName.setFocus()

        After a new record is saved, the value of the auto-generated PK should 
be available in your bizobj via self.getPK(). So your code would read:

def afterSave(self):
        newPK = self.getPK()
        dabo.ui.info("Record successfully saved. Your new number is DC10- %s" % 
newPK, title="Success")
        self.new()
        self.BuilderName.setFocus()

> Just to make things even harder on myself if the ID is a single digit (ie:
> 1) it would need to have 2 zero's in front of it to give me 001
> if it's 2 digits (ie: 12) it would have to have a single zero in front to
> give me 012. And just give the last row ID if it's 3 digits (ie: 356)

        That's a built-in Python string method: zfill

stringID = str(integerID)
print stringID.zfill(3)

> We will never have anymore than 999 entries.

        Why does my stomach feel uneasy when I read a statement like that?  ;-)


-- Ed Leafe



_______________________________________________
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