I first want to say thanks for the wonderful framework. It has allowed me to
achieve a small program needed to help track something with my job duties,
with next to nil programming experience.
That said, I need some help achieving the following, if it's even possible.
Please note that this works fine as is but I would like to add/pull one
piece of info into this info dialog box to make it easier on the end user.
After successfully adding a new record to the database, I let the user know
with the following:
def afterSave(self):
# This will only get called if the save succeeds
dabo.ui.info("Record successfully saved.", title="Success")
self.new()
self.BuilderName.setFocus()
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()
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)
We will never have anymore than 999 entries.
Any help that anyone can provide would be greatly appreciated.
Thank
Carey
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
_______________________________________________
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/a3fcd6c70912292012u521846d6y7d9fd5d431229c46@mail.gmail.com
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: 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/ECFCA9DD-0034-45E6-BE23-91A3ACF0489C@leafe.com
Author: Carey Gagnon
Posted: 2009-12-31 07:13:18 Link
Thanks Ed, but it doesn't seem to work and stops the info dialog from being
displayed at all. It also doesn't reset the form to allow for the next entry
to be made.
>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:
Does the self.getPK() actually go in the bizobj file??
The code snippet below is in the frmDC2010Add-code.py file that was created
when I made the frmDC2010Add.cdxml in the CD.
Is this the right place for it??
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()
>
I tried several things to get the info dialog to fire, which it wouldn't as
long as the newPK = self.getPK() line existed or %s" % newPK existed in the
dabo.ui.info line. I'm stumped.
> That's a built-in Python string method: zfill
>
> stringID = str(integerID)
> print stringID.zfill(3)
>
Now I just need to figure out how to use it once I get the the other part
working.
>
> > We will never have anymore than 999 entries.
>
> Why does my stomach feel uneasy when I read a statement like that?
> ;-)
>
It's a single DB per year and history shows I should be ok, and it makes my
stomach less uneasy using Dabo than keeping this thing in an MS Access DB as
it currently exists. ;^)
Any clues that might point me in the right direction are greatly
appreciated.
Thanks Again
Carey
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
_______________________________________________
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/a3fcd6c70912310413q6ff3a05dg63ec2b4d6a03ea12@mail.gmail.com
On Dec 31, 2009, at 7:13 AM, Carey Gagnon wrote:
>> 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:
>
> Does the self.getPK() actually go in the bizobj file??
>
> The code snippet below is in the frmDC2010Add-code.py file that was created
> when I made the frmDC2010Add.cdxml in the CD.
> Is this the right place for it??
>
> 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()
Ah, you misunderstood what I meant by "in your bizobj". I meant that in your bizobj code, you would call 'self.getPK()'. Outside of your bizobj, such as in your form code, you'd have to use a reference to the bizobj. E.g.:
def afterSave(self):
newPK = self.PrimaryBizobj.getPK()
dabo.ui.info("Record successfully saved. Your new number is DC10-
%s" % newPK, title="Success")
self.new()
self.BuilderName.setFocus()
> I tried several things to get the info dialog to fire, which it wouldn't as
> long as the newPK = self.getPK() line existed or %s" % newPK existed in the
> dabo.ui.info line. I'm stumped.
Since this is form code, and your form doesn't have a getPK() method, most likely Python threw an AttributeError on the call to self.getPK(). Fix the reference, and it should work.
>>> We will never have anymore than 999 entries.
>>
>> Why does my stomach feel uneasy when I read a statement like that?
>> ;-)
>
> It's a single DB per year and history shows I should be ok, and it makes my
> stomach less uneasy using Dabo than keeping this thing in an MS Access DB as
> it currently exists. ;^)
I've worked for many clients who made claims like "we will never need more than one phone number per customer" or "part numbers will never be more than 4 places" or "640K will be enough for anyone". (OK, that last one wasn't from one of my clients!).
Assuming single-year tables sure sounds like a premature optimization to me, and one that could limit the application later on.
-- Ed Leafe
_______________________________________________
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/9A213FE6-5A95-4154-9F4A-617619EAAF36@leafe.com
Author: Paul McNett
Posted: 2009-12-31 12:46:35 Link
Ed Leafe wrote:
> I've worked for many clients who made claims like "we will never need more than one phone number per customer" or "part numbers will never be more than 4 places" or "640K will be enough for anyone". (OK, that last one wasn't from one of my clients!).
It's become a running joke between myself and my principle contact at my main client.
They keep constraining what I do based on what they think will get the job done
faster (more cheaply). So they say, for example: "There will never ever be the need
for more than one t-post" which means I don't need to set up a 1:many relationship or
really do any normalization at all.
I get the job done pretty quickly and it works well. We maintain it and enhance it
over the years as needs change and business rules flex with the times. This was 1998.
Flash forward to 2006 and customers are now wanting 2-4 t-posts plus horizontal
t-posts (which were another "we'll never need this" option back then).
Now we need to either graft the new requirements onto the existing framework, or
redesign the whole module from scratch, including converting the old data to the new
model, testing, and deploying in the most non-distruptive way possible.
IOW, allowing for the 1:many design from the outset, even though the need wasn't
foreseen, and even though the need for an infinite number of t-posts would never
materialize, would have been the best decision for them, because making such a
fundamental change later on takes way more time and energy than designing it in at
the outset.
There are many such examples in my client relationships. For this one client, I make
a point of finding the original email where she says "we'll never need this" and
replying to it with a wink. But she still never learns. ;)
Paul
_______________________________________________
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/4B3CE37B.3040805@ulmcnett.com
Author: Stephen Waterbury
Posted: 2009-12-31 13:12:04 Link
Paul McNett wrote:
> Ed Leafe wrote:
>> I've worked for many clients who made claims like "we will never need more than one phone number per customer" or "part numbers will never be more than 4 places" or "640K will be enough for anyone". (OK, that last one wasn't from one of my clients!).
>
> It's become a running joke between myself and my principle contact at my main client.
> They keep constraining what I do based on what they think will get the job done
> faster (more cheaply). ...
>
> I get the job done pretty quickly and it works well. We maintain it and enhance it
> over the years as needs change and business rules flex with the times. ...
>
> There are many such examples in my client relationships. For this one client, I make
> a point of finding the original email where she says "we'll never need this" and
> replying to it with a wink. But she still never learns. ;)
In fairness to such clients (and to ourselves as well), the delicate balance between
efficiency/simplicity/cost-effectiveness and extensibility/flexibility/good architecture
is one of the most difficult aspects of software development, and one of the reasons
experienced developers are worth their salt -- that indefinable thing called
"engineering judgment" has some subtle aspects and comes through hard
lessons. It's also one of the reasons why reading/maintaining code is so much
harder than developing/writing it in the first place -- which accentuates
one of the strengths of Python: *clarity* (of course it's possible to write
obfuscated, spaghetti Python code, but Python makes clarity relatively easy).
Happy New Year, Paul and Ed -- hope to see you at PyCon! :)
Steve
_______________________________________________
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/4B3CE974.8000700@nasa.gov
Author: Stephen Waterbury
Posted: 2009-12-31 14:48:40 Link
Paul McNett wrote:
> Ed Leafe wrote:
>> I've worked for many clients who made claims like "we will never need more than one phone number per customer" or "part numbers will never be more than 4 places" or "640K will be enough for anyone". (OK, that last one wasn't from one of my clients!).
>
> It's become a running joke between myself and my principle contact at my main client.
> They keep constraining what I do based on what they think will get the job done
> faster (more cheaply). ...
>
> I get the job done pretty quickly and it works well. We maintain it and enhance it
> over the years as needs change and business rules flex with the times. ...
>
> There are many such examples in my client relationships. For this one client, I make
> a point of finding the original email where she says "we'll never need this" and
> replying to it with a wink. But she still never learns. ;)
In fairness to such clients (and to ourselves as well), the delicate balance between
efficiency/simplicity/cost-effectiveness and extensibility/flexibility/good architecture
is one of the most difficult aspects of software development, and one of the reasons
experienced developers are worth their salt -- that indefinable thing called
"engineering judgment" has some subtle aspects and comes through hard
lessons. It's also one of the reasons why reading/maintaining code is so much
harder than developing/writing it in the first place -- which accentuates
one of the strengths of Python: *clarity* (of course it's possible to write
obfuscated, spaghetti Python code, but Python makes clarity relatively easy).
Happy New Year, Paul and Ed -- hope to see you at PyCon! :)
Steve
_______________________________________________
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/4B3D0018.1020009@pangalactic.us
Author: Paul McNett
Posted: 2009-12-31 15:32:37 Link
Stephen Waterbury wrote:
> Paul McNett wrote:
>> Ed Leafe wrote:
>>> I've worked for many clients who made claims like "we will never need more than one phone number per customer" or "part numbers will never be more than 4 places" or "640K will be enough for anyone". (OK, that last one wasn't from one of my clients!).
>> It's become a running joke between myself and my principle contact at my main client.
>> They keep constraining what I do based on what they think will get the job done
>> faster (more cheaply). ...
>>
>> I get the job done pretty quickly and it works well. We maintain it and enhance it
>> over the years as needs change and business rules flex with the times. ...
>>
>> There are many such examples in my client relationships. For this one client, I make
>> a point of finding the original email where she says "we'll never need this" and
>> replying to it with a wink. But she still never learns. ;)
>
> In fairness to such clients (and to ourselves as well), the delicate balance between
> efficiency/simplicity/cost-effectiveness and extensibility/flexibility/good architecture
> is one of the most difficult aspects of software development, and one of the reasons
> experienced developers are worth their salt -- that indefinable thing called
> "engineering judgment" has some subtle aspects and comes through hard
> lessons. It's also one of the reasons why reading/maintaining code is so much
> harder than developing/writing it in the first place -- which accentuates
> one of the strengths of Python: *clarity* (of course it's possible to write
> obfuscated, spaghetti Python code, but Python makes clarity relatively easy).
I know, it is always a little fuzzy where to draw the line between puritanism and
pragmatism. I don't mind getting paid to be the ultimate decider (or at least the
presenter of all the choices).
> Happy New Year, Paul and Ed -- hope to see you at PyCon! :)
Happy New Year too, Stephen! Glad to know you'll be attending PyCon and I look
forward to seeing you there.
Paul
_______________________________________________
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/4B3D0A65.2020101@ulmcnett.com
Author: Carey Gagnon
Posted: 2010-01-01 07:13:16 Link
Your clarification did the trick Ed. Thanks so much. Works like a charm!!
--Carey
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
_______________________________________________
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/a3fcd6c71001010413i382f5bc5ne45786796b867e2f@mail.gmail.com
Author: Carey Gagnon
Posted: 2010-01-01 08:09:25 Link
One other thing.
This displays all the info I want it to:
def afterSave(self):
# This will only get called if the save succeeds
newPK = self.PrimaryBizobj.getPK()
stringID = str(newPK)
dabo.ui.info("Record successfully saved. Your new DC number is DC10- %s"
% stringID.zfill(3), title="Success")
self.new()
self.BuilderName.setFocus()
Can the message text be made to display on more the one line (new line, page
break, br...etc)
The message currently displays as:
Record successfully saved. Your new DC number is DC10-003
I would like it to display as:
Record successfully saved.
Your new DC number is DC10-003
Thanks again and happy new year!
Carey
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
_______________________________________________
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/a3fcd6c71001010509mbce7f67t156bc06151c734e9@mail.gmail.com