On 9/16/11 1:31 AM, Vineet Deodhar wrote:
> #here, customizing the validation code for this bizobj
>      def validateRecord(self):


>Raise an exception at the top of your validateRecord() code, to make sure the 
>code is even being called:
>def validateRecord(self):
>    raise ValueError, "hi"
>    # or:
>   1/0
>Paul

================
Paul,
Your hint was useful.
What I observed is this---
While saving a changed record, the validateRecord() code fires.
But it is not getting fired while saving newly added record.

I referred to an earlier thread http://leafe.com/archives/msg/435264 regarding 
this.
I am also aware that DABO code is modified in trunk to validate new unchanged 
record.
I have downloaded DABO in July 2011.

Still, my customised validateRecord() method is not catching the error.
Can somebody pl. suggest a workaround regarding this issue?
======================================
For ready reference, my code is reproduced as under--------
class PublicTtlBizobj(dabo.biz.dBizobj):
    def afterInit(self):
        self.DataSource = 'ttl'
        self.KeyField = 'ttlid'
        self.addField('ttlid')
        self.addField('ttlnm')
        self.UserSQL = 'select * from ttl'
        self.NonUpdateFields = ['ttlid']

#here, customizing the validation code for this bizobj
    def validateRecord(self):
        if self.getFieldVal('ttlnm') == '':
            return "Title Name must not be blank"
        
        type_of_ttlnm = self.getFieldVal('ttlnm')
        if type(type_of_ttlnm) == int:
            return "Title Name must not be Integer"
-----------end of code----------------
on the python shell,
>> ttlBizObj = PublicTtlBizobj(testconn)
>> ttlBizObj.requery()
>> ttlBizObj.new()
>> ttlBizObj.setFieldVal('ttlnm', '')
>> ttlBizObj.save()
business rule is violated because 'ttlnm' field is kept blank.

==========================================
Thanks,
Vineet

--- StripMime Report -- processed MIME parts ---
multipart/alternative
  text/plain (text body -- kept)
  text/html
---
_______________________________________________
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