Select to view content in your preferred language

Updating ToolValidator script... having issues with function parameters

493
2
Jump to solution
07-23-2012 03:22 AM
AndrewJones
Deactivated User
Hi all,

I am modifying the ToolValidator class script for a tool and I am adding an additional class to the script that does an Oracle lookup to set an initial value.

However, I am experiencing an issue when the script is analyzed as I save/apply it.

I am getting the following error...

initializeParameters Execution Error: Runtime error <type 'exceptions.TypeError'>: dd() takes exactly 2 arguments (3 given)


... using the following code...

class UserDetails:     def __init__(self):           #... code ommited...                  self.folder = self.dd("secretKey","xyz")              def dd(key, e):         return 'ddValue' #... code modified to protect content    class ToolValidator:   """Class for validating a tool's parameter values and controlling   the behavior of the tool's dialog."""    def __init__(self):     """Setup arcpy and the list of tool parameters."""     import arcpy, os     self.params = arcpy.GetParameterInfo()    def initializeParameters(self):     """Refine the properties of a tool's parameters.  This method is     called when the tool is opened."""          ud = UserDetails()     loc = self.params[0]     loc.Value = ud.folder          return    def updateParameters(self):     """Modify the values and properties of parameters before internal     validation is performed.  This method is called whenever a parmater     has been changed."""              return    def updateMessages(self):     """Modify the messages created by internal validation for each tool     parameter.  This method is called after internal validation."""     return


Any clues as to why it is saying that I have passed one more argument to the dd function than I appear to have done?

Thanks
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JasonScheirer
Esri Alum
Change

    def dd(key, e):


to

    def dd(self, key, e):

View solution in original post

0 Kudos
2 Replies
JasonScheirer
Esri Alum
Change

    def dd(key, e):


to

    def dd(self, key, e):
0 Kudos
AndrewJones
Deactivated User
Change

    def dd(key, e):


to

    def dd(self, key, e):


That sorted it thanks. I think I need to go back and get a python refresher!
0 Kudos