Worked out the solution - see below!
def beforeDelete(self):
ret = ""
# if a member has this type do not allow delete
app = self.Application
conn = app.getConnectionByName("LodgeBooks")
con = conn.getConnection()
c = con.cursor()
c.execute("select * from Members where MembershipType = %s" %
(self.Record.MTypeID))
if c.fetchone() != None:
ret = "value in use."
return ret
Regards, Rodgy
----- Original Message -----
From: "Ed Leafe" <[email protected]>
To: "Dabo Users list" <[email protected]>
Sent: Monday, January 19, 2009 3:41 PM
Subject: Re: [dabo-users] Validation before Delete
> On Jan 18, 2009, at 10:34 PM, Roger Lovelock wrote:
>
>> Some advice on the 'dabo' way to do this!
>>
>> In my bizObj I have a beforeDelete method where I want to stop the
>> deletion if a reference to the record occurs in another table (ie
>> this table is membership types - I don't want to allow deletion of a
>> membership type if a member exists with this type on their record).
>
>
> Generally that's handled by referential integrity rules in the
> database. If you aren't using a RDBMS that supports this, then your
> approach is fine. As far as the connection goes, bizobjs have a
> 'protected' attribute named 'self._connection' that you can use.
>
>
> -- Ed Leafe
>
>
>
>
[excessive quoting removed by server]
_______________________________________________
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/8199e259bff846b6a53010d46742d...@roger