hi again. OK. I tried this to get the files in my directory into an array (even those in the subdirectory). I got the file objects into the array, but i can't seem to clear the array afterwards. so everytime i run the dtml method, the array keeps appending. this is the DTML <dtml-in expr="test_script()" sort="bobobase_modification_time" reverse> <dtml-var id> - <dtml-var bobobase_modification_time fmt="aCommon"><br> </dtml-in> this is test script - i got this from zopelabs. I just modified it so that the contents of the folder will be loaded into the array #parameters obj=None, results=[] if obj is None: # start 'here' unless else is specified obj = context # loop though everything! for object in obj.objectValues(): # is the object folderish if object.isPrincipiaFolderish: # go deeper print "Folderish title: %s"%object.title_or_id() ##### start of my code ##### folderName = object.getId() for file in obj[folderName].objectValues('File'): print " %s" %file.getId() results.append(file) print "<br>" ##### end of my code ##### print context.test_script(object) # return printed return results anyone can help me? thanks in advance! __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com
michael.tañag wrote:
hi again.
OK. I tried this to get the files in my directory into an array (even those in the subdirectory). I got the file objects into the array, but i can't seem to clear the array afterwards. so everytime i run the dtml method, the array keeps appending.
I assume that you mean "everytime I call the dtml-method in the same request ...", i.e. if you do a reload on that page, you won't get this appending, right? But anyway, there's ZopeFind which can do that job for you, try that in a python script: startfolder = container list = container.ZopeFind( startfolder, obj_metatypes=['File'], search_sub = 1) return list where startfolder is the folder which should be the root of the hierachy you want to search in. This returns a list of tuples (object_id, object) analogous to objectValues(), but recursive. HTH, oliver
michael.tañag wrote at 2003-1-8 02:39 -0800:
OK. I tried this to get the files in my directory into an array (even those in the subdirectory). I got the file objects into the array, but i can't seem to clear the array afterwards. so everytime i run the dtml method, the array keeps appending. What you call an "array" is usually called a "list".
You clear a list with "del list[:]" or you assign a new empty list with "results= []". Dieter
participants (3)
-
Dieter Maurer -
michael.ta�ag -
Oliver Bleutgen