Problem passing absolute path to a external method
Hi when I run in Python a script it runs fine, but when I put it on the extension folder of Zope and added the external method in the Zope folder where I need to start the search, this returrn an error that say " Zope Error Zope has encountered an error while publishing this resource. Error Type: IOError Error Value: [Errno 2] No such file or directory: 'chr1/CDS.htm'" The external method is in a folder called database, inside that folder are 14 folders called chr1, chr2, chr3 etc..., and inside any folder is a DTML document called CDS.htm. I already know the proble is something with the absolute path, but I don't know how I can pass this value to the external method, I really need to use those files from the ZODB because they are used to show it if somebody request it from a search in the Zcatalog. Thanks to all. Here is the code of the script make in Python # -*- coding: cp1252 -*- """ Script realizado por Miguel Angel García Belandria """ """Debe ser guardado en el directorio /home/Zope/Extensions para posteriormente ser llamado como método externo de Zope""" import sys,re files=['chr1/CDS.htm','chr2/CDS.htm','chr3/CDS.htm'] def rifin(): gi=giclean="" rifin=h=0 for h in files: i=j=0 file=open(h,"ra") print "Searching in file %s ..." % h texto=file.read() file.close """Buscar RIFIN""" while i < len(texto): if texto[i]=="R" or texto[i]=="r": if texto[i+1]=="I" or texto[i+1]=="i": if texto[i+2]=="F" or texto[i+2]=="f": if texto[i+3]=="I" or texto[i+3]=="i": if texto[i+4]=="N" or texto[i+4]=="n": rifin=rifin+1 j=i-1 while not(texto[j])==";": gi=texto[j]+gi j=j-1 i=i+1 """Buscar los GI solamente""" cont=i=0 while i < len(gi): if gi[i]=="g": if gi[i+1]=="i": j=i if cont==0: giclean=giclean elif cont<3: giclean=giclean+" - " else: giclean=giclean+"\n" cont=0 cont=cont+1 while j <i+12: giclean=giclean+gi[j] j=j+1 i=i+1 print "Se encontraron %d resultados compatibles con RIFIN" % rifin print giclean for h in files: print "|File: %s|" % h, --------------------------------- Do You Yahoo!? Todo lo que quieres saber de Estados Unidos, América Latina y el resto del Mundo. Visíta Yahoo! Noticias.
participants (1)
-
Miguel Angel Garcia Belandria