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'
            else:
                searchAssetType(object)
    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
partNumber.

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
Objects.

for example follwing is the hieracy of AssetType Objects

--computer
     -pc
     -laptop
     -tablet

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
http://localhost:8082/dtitrackmodule/assettracking.2005-04-13.1452962360/assettypefolder.2005-04-13.1594566344/testscript
Traceback (most recent call last):
  File "/home/reuben/zope/lib/python/ZPublisher/Publish.py", line 101, in
publish
    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
call_object
    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
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to