On Oct 26, 2009, at 7:59 AM, Miguel Lopes wrote:
> I have a record that is created in code. All it takes to create it is
> a string, thus I'm using a dabo.ui.getString() dialog to get the
> string from the user.
> This lead me to wonder about where would be the best place to catch a
> validation exception (dabo.dException.BusinessRuleViolation).
>
> I'm tempted to catch it in the bizobj and then return an empty string
> in case it is valid or a string with the error message if it's not
> valid.
Why not use the built-in exception?
try:
myBiz.validateUserInput(val)
except dException.BusinessRuleViolation, e:
dabo.ui.stop("Invalid entry: %s" % e)
It's a much more Pythonic approach, and keeps the UI separate from
the bizobj layer logic.
> This way the client code (in a form) can alert the user. On the other
> hand I could just show the dialog from the bizobj, which doesn't seem
> like a good idea (for readability), although in many cases this
> wouldn't be a problem.
It might work, but it will result in a horribly difficult to maintain
application. Dabo is designed to use a 3-tier approach to coding, in
which UI, business logic and data access are all kept independent of
each other.
> It also crossed my mind that this could interfere with Springboard.
> Since I don't know if the bizobj runs remotely or locally.
If you want to add additional bizobj methods that will work as a
remote bizobj, look at the code in dBizobj.py for methods such as
save(), requery(), etc., to see how to make this work.
-- 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]