[Zope] Re: Embedding java applet into python Product

Josef Meile josef.meile at imes.mavt.ethz.ch
Wed May 12 04:53:33 EDT 2004


 > Create a public method inside your product class that renders just the
 > binary, i.e 'jclass_binary'.
 > Then you use, according yo your appletHeader method:
 >
 > self.absolute_url() + '/jclass_binary'
 >
 > ... as the url that you need in the 'code' attribute of the applet tag.
I don't know how this binary rendering should be done. This is what I 
have tried:

   def loadAppletClass(self):
     """Returns the binary data"""
     productHome=Globals.package_home(globals())
     appletName='myApplet.class'
     appletPath=os.path.join(productHome,'java/'+appletName)
     appletData=file(appletPath)
     return appletData.read()

then:

   def appletHeader(self):
     """Renders the applet tag"""
     return \
     """
           <applet code="%s" width="%s" height="%s"
                   name="myApplet">
             <param name="showValue" value="no">
             <param name="sampleHeight" value="10">
             <param name="bgColor" value="%s">
             no applet
           </applet>
     """ % 
(self.absolute_url()+'/loadAppletClass',self.appletWidth,self.appletHeight,self.
bgColor[1:])

But I didn't succeded. The applet isn't started. When I call the method 
loadAppletClass alone, then I see the binary data of the applet.

 >
 > Have in mind that by doing this way you won't be able to manage the 
cache
 > settings of the binary, unless you deal with that within the method 
itself,
 > so chances are that you'll prefer to upload your java class as a visible
 > zope file.
Yes, I've already thaugth about it, but I don't like this way because 
when the user uninstalls the product, the java applet will remain 
somewhere on the zope DB.

Another way is to store the java applet on the "Control_Panel/MyProduct" 
folder on the initialization time, which I've done, but then I have to 
use this path on the "applet" tag and I don't like it because it exposes 
the "Control_Panel" folder (ie: malicious bots will see it).

Thanks,
Josef



More information about the Zope mailing list