Give your script an absolute directory rather than a relative one. Zope will be look for your files in a directory other than the one you except, normally its the INSTANCE_HOME (where z2.py) is located. Miguel Garcia wrote:
Hi, I'm New with Zope, and I need to make a external method to open a file, search some things and return those values, I have the script already make in Python. When I run in Python 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. Please help me with this because I don't know what's the problem.
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!?* <http://espanol.yahoo.com/mail_tagline/*http://espanol.news.yahoo.com> Todo lo que quieres saber de Estados Unidos, América Latina y el resto del Mundo. Visíta Yahoo! Noticias <http://espanol.yahoo.com/mail_tagline/*http://espanol.news.yahoo.com>.
------------------------------------------------------------------------
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
------------------------------------------------------------------------
This message has been 'sanitized'. This means that potentially dangerous content has been rewritten or removed. The following log describes which actions were taken.
Sanitizer (start="1063114430"): Part (pos="1958"): Part (pos="188"): SanitizeFile (filename="unnamed.txt", mimetype="text/plain"): Match (rule="9"): Enforced policy: accept
Part (pos="3581"): SanitizeFile (filename="unnamed.html", mimetype="text/html"): Match (rule="9"): Enforced policy: accept
Note: Styles and layers give attackers many tools to fool the user and common browsers interpret Javascript code found within style definitions. References: - http://www.securityfocus.com/bid/630 - http://archives.indenial.com/hypermail/bugtraq/2001/January2001/0512.html Rewrote HTML tag: >>_DIV_<< as: >>_DEFANGED_DIV_<< Rewrote HTML tag: >>_DIV_<< as: >>_DEFANGED_DIV_<< Rewrote HTML tag: >>_/DIV_<< as: >>_/DEFANGED_DIV_<< Rewrote HTML tag: >>_/DIV_<< as: >>_/DEFANGED_DIV_<<
Part (pos="15001"): SanitizeFile (filename="unnamed.txt", mimetype="text/plain"): Match (rule="9"): Enforced policy: accept
Total modifications so far: 4
Anomy 0.0.0 : Sanitizer.pm Sanitizer version 1.59 (Debian GNU/Linux)
-- Andy McKay http://www.agmweb.ca