On Jul 21, 2012, at 3:01 PM, Dave Kelly wrote:

> I am unsure about the best approach for this.  If I use the onLostFocus
> event on the password field, how do I look for a record to test whether it
> is a valid username and password combination and if it is valid,  do I write
> the code to populate the form in the form itself or is there a way to call
> something from Bizobj?

        I would do something like this: when the form comes up, have it show a 
modal dialog with fields for the username/password. When they click 'OK', take 
the values entered and do your validation. If it isn't valid, alert them and 
give the option to re-try. If it is valid, then use the info to query for the 
relevant records. Something like this (in the form):

def login(self):
    class UserPassDialog(dabo.ui.dStandardButtonDialog):
        def afterInit(self):
            self.txtUsername = dabo.ui.dTextBox(self)
            self.txtPW = dabo.ui.dTextBox(self, PasswordEntry=True)
            # Code to create the labels, sizer, etc.
            ...

    dlg = UserPassDialog(self, OK=True, Cancel=True)
    dlg.show()
    if dlg.Accepted:
        # User didn't cancel
        user = dlg.txtUsername.Value
        pw = dlg.txtPW.Value
        biz = self.getBizobj("timeclock")   # or whatever your bizobj is
        # The next method is whatever you need to validate credentials
        if not biz.checkLogin(user, pw):
            dabo.ui.stop("Invalid username and/or password")
            return
        # Set the params for the bizobj
        biz.setParams(user)
        # I'm assuming that your bizobj is set to query based on username...
        self.requery()


        Hope that gets you started...


-- 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