[Zope] Re: Java class doesn't load correctly under windows

Josef Meile jmeile at hotmail.com
Tue Aug 24 12:09:05 EDT 2004


--- In zope at yahoogroups.com, Chris Withers <chris at s...> wrote:
 > Josef Meile wrote:
 > >   #Remove leading slash
 > >   if (zopePath[-1]=='/') and (pathLen>1):
 > >     zopePath=zopePath[0:pathLen-1]
 >
 > maybe you should use os.sep instead of '/' there?
 >
 > >   if zopePath[0]!='/':
 >
 > ...and here.
 >
 > >     zopePath='/'+zopePath
 >
 > ...and here, but i can't see where zopePath comes from so I may be wrong.
No, zopePath isn't a file system path, it's a path on the ZopeDB. If I'm 
not wrong they are always separated with "/".

 >
 > >   if folder!='':
 > >     try:
 > >       manage_addFolder(fileContainer,folder,'JMFiles')
 > >     except:
 > >       #The Folder already exists
 > >       pass
 >
 > This is an EXTREMELY silly piece of code. Bare excepts like this are
 > asking for all manner of trouble.
Oh yes, you are right. Now I realize that manage_addFolder can also fail 
due other conditions (ie: invalid characters on the id). Thanks for 
pointing it out :-)


 >
 > >     fileFolder=getattr(fileContainer,folder)
 > >   absolutePath=os.path.join(filePath,fileName)
 > >   data=file(absolutePath)
 >
 > oops, that'll be the main source of your problem.
 >
 > should be:
 > data = file(absolutePath,'rb')
You were right, how didn't I realize it before? Off course the java 
class file is binary and I guess the default opening mode on windows is 
text.


 >
 > >   try:
 > >     manage_addFile(fileFolder,fileName,file=data,
 > >                    title=title)
 > >   except:
 > >     #The file was already created on a previous session
 > >     pass
 >
 > More brain-dead-ed-ness :-(
Again, you are right. I promise to change it.

Thanks,
Josef


More information about the Zope mailing list