From: Terry H. <ha...@an...> - 2002-02-26 18:50:46
|
Nicolas Bill Russell wrote: > I just want to know if Jython is supported by Zope? I'm new to Python > so go easy on me. :) As far as I know (and I've been looking -- still am), there's no direct support for Jython in Zope. However, Jython is strictly a *client-side* technology and Zope is strictly *server-side* -- so in principle, there isn't much overlap. You could use DTML Methods/ Documents and File objects to hold the Jython code and the interpreter. What would be kind of cool, though, is a Zope product to encapsulate a Jython applet as a Zope object. I think it ought to: 1) Provide a syntax-sensitive editing interface (can we just use the one currently provided for Python scripts? I'm not sure if the syntax is similar enough. I mean -- is the syntax checker aware of standard modules (which may differ) or just legal Python syntax (which should be the same)? Actually, it occurs to me that this may not really be a "syntax checker" -- is it actually just importing the module and reporting the traceback from that? In which case, this is really the same as #3 below. 2) Automatically provide the wrapper code to deliver the Jython interpreter applet and generate the correct <applet> tags, etc. This would be akin to what Zope does for images. 3) It might be good to actually pre-compile into a .jar file (or whatever is appropriate -- I'm a Java/Jython newbie, so go easy on _me_ too ;) ), on the server. Probably one should do this whenever the program is edited on the server, and report errors/traceback from the program. This probably has to be done from an unrestricted Python module (which may in turn call other programs on the server, such as jythonc), so that means putting it in as an External method, or (better) including it in a Zope Product. With Jython, there's an obvious cache-optimization problem -- you want to make sure you only download the core/interpreter part once, and the applets separately. You also want to avoid triggering various security problems with client-side code, which seem to happen when you evaluate/execute strings inside of Python. This probably ought to be done on the server if it can't be avoided (?). It seems to me that there's enough repetitive work here to justify making a special product to simplify it. If you had this, I think you could just edit a Jython client-side method in Zope, save it (which would compile and store on the server), and then embed it into a DTML document, using <dtml-var myJythonObject>. I was thinking of waiting until the O'Reilly book on Jython comes out (I'm not experienced at Java, so I don't think the other book is going to help me so much), and then having a go at writing such a product myself, since I want to do a fairly large amount of Jython stuff with Zope. My attraction to this is the beauty of having both server and client programmed in the same programming language (Python), instead of having to learn and interface between two different ones. This would also reduce the burden of deciding where to draw the line between server- and client-side components, since they would then be relatively easy to port back and forth. So ... Has anyone already done this (and I'm just not so good at finding it), or is anyone interested in collaborating / discussing this with me? Cheers, Terry -- ------------------------------------------------------ Terry Hancock ha...@an... Anansi Spaceworks http://www.anansispaceworks.com P.O. Box 60583 Pasadena, CA 91116-6583 ------------------------------------------------------ |