hi all,

i have problem in the validation of checking duplicate values for the
unicode column fields in a table whose model is like,

class Compnode(SQLObject):

        name = UnicodeCol(alternateID=True,length=20)
        host = UnicodeCol()
        hypervisor = StringCol()

there is a conflict because,when we try to edit a column say host.we
press the save button in the form and in turn it shows that "Name
already in use" whisch is an error for   name column.please help to
overcome this problem and the program is,

@expose(template="webtool.templates.edit_node")
def update_node(self,**postvars):
        self.validate_login()
        error={}
        select_node=Compnode.byName(postvars['varName'])
        if self.validity.isPlainText(postvars['varCompName']) != True:
                error['compname'] = "Enter a valid Name"
        else:
**              dup_name=Compnode.selectBy(name=postvars['varName'])
                if dup_name.count() > 0:
                        error['compname'] = 'Name already exists'  ***

        if self.validity.isPlainText(postvars['varHost']) != True:
                error['hostname'] = "Enter a valid Host name"
        else:
***             dup_host=Compnode.selectBy(host=postvars['varHost'])
                if dup_host.count() > 0:
                        error['hostname'] = 'Name already exists'***

        if len(error) > 0:
                return dict(error=error,node=select_node)
        else:
                select_node.name=postvars['varCompName']
                select_node.host=postvars['varHost']
                select_node.hypervisor=postvars['varCompHyper']
                redirect('/node_list')


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to