I am trying to have a script work in zmi that has recursion in it.i am posting
the simple version of the my script (i called it testscript) code here

def searchAssetType(param_object):
    for object  in param_object.objectValues('AssetType'):
        if (object.getPartNumber()):
            pn = object.getPartNumber().getPartNumber()
            if (pn==partNum):
                return 'found'
    return 'fail'
return searchAssetType(context)

i have a hirarchy of Objects of type AssetType. so an object of type AssetType
can contain another object of type AssetType. now the above script is written
to seearch for an object of type AssetType based on its attribute called

but the above script is not working for children objects..so if i search for the
AssetType  on the top level it works fine but doesnt work for children AssetType

for example follwing is the hieracy of AssetType Objects


it works for computer but doesnt work for its children. if i give partNumber of
computer, the script returs found but returns fail for any of  other
AssetType's partNumber..

here is the stack trace..please help me.
2005-04-15T10:32:36 ERROR(200) SiteError
Traceback (most recent call last):
  File "/home/reuben/zope/lib/python/ZPublisher/Publish.py", line 101, in
    request, bind=1)
  File "/home/reuben/zope/lib/python/ZPublisher/mapply.py", line 88, in mapply
    if debug is not None: return debug(object,args,context)
  File "/home/reuben/zope/lib/python/ZPublisher/Publish.py", line 39, in
    result=apply(object,args) # Type s<cr> to step into published object.
  File "/home/reuben/zope/lib/python/Shared/DC/Scripts/Bindings.py", line 306,
in __call__
    return self._bindAndExec(args, kw, None)
  File "/home/reuben/zope/lib/python/Shared/DC/Scripts/Bindings.py", line 343,
in _bindAndExec
    return self._exec(bound_data, args, kw)
  File "/home/reuben/zope/lib/python/Products/PythonScripts/PythonScript.py",
line 323, in _exec
    result = f(*args, **kw)
  File "Script (Python)", line 11, in testscript
  File "Script (Python)", line 3, in searchAssetType

Zope3-users mailing list

Reply via email to