[Zope] Problem with external methods in ZOPE
Brian Lloyd
brian at zope.com
Tue Sep 9 11:06:35 EDT 2003
Hi Miguel -
Your script works from the command line because your working
directory happens to be correct.
When running under Zope, the current working directory can't
be depended on to get the right path - if you change your
script to use absolute paths things should work as expected.
Hope this helps,
Brian Lloyd brian at zope.com
V.P. Engineering 540.361.1716
Zope Corporation http://www.zope.com
-----Original Message-----
From: zope-bounces at zope.org [mailto:zope-bounces at zope.org]On Behalf Of
Miguel Garcia
Sent: Tuesday, September 09, 2003 8:40 AM
To: zope at zope.org
Subject: [Zope] Problem with external methods in ZOPE
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!?
Todo lo que quieres saber de Estados Unidos, América Latina y el resto del
Mundo.
Visíta Yahoo! Noticias.
More information about the Zope
mailing list