Embedding java applet into python Product
Hi, 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: #MyInstanceHome/Products/MyProduct/java/myApplet.class productHome=Globals.package_home(globals()) appletName='myApplet.class' appletPath=os.path.join(productHome,'java/'+appletName) #Then loads the data appletData=file(appletPath) return File(appletName,'',appletData) #return appletData -> I tried this as well #Creates a global variable to store the #file reference APPLET_CLASS=loadAppletClass() #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> """ % (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 </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 </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, Josef
participants (1)
-
Josef Meile