[Zope] Embedding java applet into python Product

Josef Meile jmeile at hotmail.com
Tue May 11 14:26:59 EDT 2004


the idea of this is to have the instances of a python product to use a 
java applet, which comes with the product itself.

This is what I've done, but I haven't had any success:

On MyInstanceHome/Products/MyProduct/MyProduct.py:

from OFS.Image import File
import os,Globals

def loadAppletClass():
   #Gets the physic path where the applet is:

   #Then loads the data
   return File(appletName,'',appletData)
   #return appletData -> I tried this as well

#Creates a global variable to store the
#file reference

#Here comes the usual code for manage_add

# Then the class definition
class MyProduct(SimpleItem):
   """ MyProduct class definition"""

   #__init__ and other class methods come here

   #Inside this method, I use some class variables that
   #I have already initialize on the __init__ method
   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_CLASS,self.appletWidth,self.appletHeight,self.bgColor)

then I called it from a Page template like this:

<applet tal:replace='structure python:here.appletHeader()'>
   Some Applet

but I get:

<applet code="---> The whole binary data comes here <---"
         width="325" height="100" name="myApplet">
             <param name="showValue" value="no">
             <param name="sampleHeight" value="10">
             <param name="bgColor" value="#eeeeee">
             no applet

I think this result is pretty normal because on one hand I'm returning 
the object contents and not a reference. On the other hand, the binary 
data is being treated as ASCII. How do I return a reference instead of 
returning the File object itself?

Thanks in advanced,

More information about the Zope mailing list