Did anyone try to port Zope to Java (using JPython)? But why do I think it's nice to have a Java-Zope? - using Java classes with Zope - running servlets and/or running Zope as servlet - performance could benefit from JIT compilers or compile Zope as native binary (gcj) - portability? not sure if Java is more portable than Python ;) Smoerk
"smoerk@gmx.de" wrote:
Did anyone try to port Zope to Java (using JPython)?
I guess that to basic technologies of Zope, ExtensionClass and Aquisition, are not ported to JPython.
But why do I think it's nice to have a Java-Zope?
- using Java classes with Zope
Any concrete class you want to run ?
- running servlets and/or running Zope as servlet
Why would you want to run servlets ? Why not PHP/ASP/Basic/XYZ scripts :)
- performance could benefit from JIT compilers or compile Zope as native binary (gcj)
I suspect that even after benefiting from JIT compilers it would be slower than native python ;-)
- portability? not sure if Java is more portable than Python ;)
The only architecture I know that has java and does not have python is PalmPilot. ----------- Hannu
Smoerk, I totally agree. I would love to have Zope/JPython running on Java. Use java for heavy-lifting (speed a la C++, deluxe garbage collection, GUI, etc.) and JPython for everything else. Servlets would be great if nothing else than to take advantage of all the Java Servlet code that's coming available to tie some servlet(s) into Zope (or just using it/them from Zope). Automatic dovetail with Java object model would an absolute godsend. Get Zope communicating with Java applets hassle free and fairly efficiently (XML-RPC may be pretty hassle-free but requires XML (gulp) and not efficient). XML-RPC is the best standards based approach I know of now. I think dovetailing Zope with Java would make a whole lot of "alternative technology" folk far more comfortable with Zope (think checkbox: "Does it support Java?"). Basically, I think there's an attitude with many technologies, that if you're not for them, you're against them. If it's not that, just the sheer convenience of built-in support would be worth a lot. Plus, Zope could become embeddable in any Java solution. That would be great for Zope. -=- The speed-up might be there. It certainly seems like there should be some. However, JPython is not optimized yet and is really still a work in progress. There's some idea that Python could morph/evolve in two or so years (i.e., a long time). One possibility for this morph would be to dovetail with Java better (i.e., to run on JVM's better). Right now, the Python language is 'defined' (i.e., implemented in CPython and emulated in JPython) so that primitive types in Java are not taken fully advantage of (I believe). Apparently, with a few tweaks (but unfortunately not backwards compatible tweaks) to the Python language, JPython could run magnitudes faster (on the order of 10-100x faster). Needless to say, that would make for a great scripting language. All of this is pie in the sky and a long way a way. The reason it's possible is that Guido (father of Python) is with the advent of JPython considering actually defining Python formally, i.e., separately from CPython. They never needed that before JPython came along. He's also made some noises (as I understand it) that a rev2 Python may be in the works. I assume these two efforts would be related but I could be wrong. -=- Finally, on a coder side, there's been some discussion on this topic before. DC has reflected on the subject and pointed out some non-trivialities of porting to Java (mainly (?) C code). I imagine it's non-trivial, but getting something running might be reasonable. I don't know if there would be any licensing restrictions; I'm afraid (???) the ZODB has some funny license for use only with Zope. I don't know if a Java Zope would still be Zope or what any licensing snafus would do. Also, DC has never sounded enthusastic about Java though it's been mentioned in terms of "strategic direction". I don't really understand what the scoop on that is. That's all. Good post!-) = Joe "Just trying to understand Zope 101 before jumping off the deep end" Grace = "smoerk@gmx.de" wrote:
Did anyone try to port Zope to Java (using JPython)?
But why do I think it's nice to have a Java-Zope?
- using Java classes with Zope - running servlets and/or running Zope as servlet - performance could benefit from JIT compilers or compile Zope as native binary (gcj)
- portability? not sure if Java is more portable than Python ;)
Smoerk
_______________________________________________ Zope maillist - Zope@zope.org http://www.zope.org/mailman/listinfo/zope
(Related lists - please, no cross posts or HTML encoding!
To receive general Zope announcements, see: http://www.zope.org/mailman/listinfo/zope-announce
For developer-specific issues, zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
At 05:06 03/11/99 , Joe Grace wrote:
Finally, on a coder side, there's been some discussion on this topic before. DC has reflected on the subject and pointed out some non-trivialities of porting to Java (mainly (?) C code). I imagine it's non-trivial, but getting something running might be reasonable. I don't know if there would be any licensing restrictions; I'm afraid (???) the ZODB has some funny license for use only with Zope. I don't know if a Java Zope would still be Zope or what any licensing snafus would do.
I don't see what you mean about the license. ZODB is covered by the same Open license as the rest of Zope, and it only requires you to state that: This product includes software developed by Digital Creations for use in the Z Object Publishing Environment (http://www.zope.org/). As for he C code, if you get Acquisition to work in Java, you're halfway there. That is the hardest piece of Zope to convert I think. -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
"MP" == Martijn Pieters <mj@antraciet.nl> writes:
MP> As for he C code, if you get Acquisition to work in Java, MP> you're halfway there. That is the hardest piece of Zope to MP> convert I think. There are some parallels to Acquisition already in JPython, although the ideas haven't been formalized or used to the extent they are in ExtensionClasses. I know JimH was aware of JimF's work here when he designed the mechanism, and it's something that I am quite interested in exploring with JPython. Essentially, when an attribute is found on a JPython object, a call is made to a method of the returned object, passing in the container of the object. In JPython the method is a Java method called _doget(), which can't be overridden in Python. From my understanding of Acquisition's basic model, _doget() plays the same role that __of__() plays. At some point, it would neat to standardize all this so things would work the same in JPython as in CPython/EC. _doget() is a key piece of the JPython machinery even apart from any Acquisition-y things it might be used for. -Barry
Martijn Pieters wrote:
I don't know if there would be any licensing restrictions; I'm afraid (???) the ZODB has some funny license for use only with Zope. I don't know if a Java Zope would still be Zope or what any licensing snafus would do.
I don't see what you mean about the license. ZODB is covered by the same Open license as the rest of Zope, and it only requires you to state that:
This product includes software developed by Digital Creations for use in the Z Object Publishing Environment (http://www.zope.org/).
Martijn, I could well be wrong. My vague recollection was that ZODB (or something else?) was licensed from someone outside DC for use only in Zope. I never really understood what the deal was, just that that chunk existed separately as a full-fledged product somewhere else. (Sound familiar to anyone?) In any case, I'd be very glad to be wrong on this!-) Then no legal snafus in duplicating code. = Joe =
At 21:09 3-11-99 , Joe Grace wrote:
I could well be wrong. My vague recollection was that ZODB (or something else?) was licensed from someone outside DC for use only in Zope. I never really understood what the deal was, just that that chunk existed separately as a full-fledged product somewhere else. (Sound familiar to anyone?)
That's ZServer which is based on Medusa. But if you get far enough converting Zope to JPython, you'll be able to write a replacement. -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | T: +31 35 7502100 F: +31 35 7502111 | mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ---------------------------------------------
[Joe Grace, on Wed, 03 Nov 1999]: :: :: I could well be wrong. My vague recollection was that ZODB (or something :: else?) was licensed from someone outside DC for use only in Zope. I never :: really understood what the deal was, just that that chunk existed separately :: as a full-fledged product somewhere else. (Sound familiar to anyone?) Yes. It sounds like ZServer (Medusa), not ZODB.
At 08:06 PM 11/2/99 -0800, Joe Grace wrote:
Finally, on a coder side, there's been some discussion on this topic before. DC has reflected on the subject and pointed out some non-trivialities of porting to Java (mainly (?) C code). I imagine it's non-trivial, but getting something running might be reasonable.
Actually, no, it isn't. The only part of Zope which might be 'reasonable' is the ZPublisher bit, and even it makes heavy use of reflection (see below). Here are just a few of the things I'm aware of: * Reflection: Zope makes heavy use of Python internals, such as function metadata and examination of bytecodes used in Python expressions. These are not available in JPython, and it's not even a C issue, just a Python implementation issue. One reason some of these items don't exist in JPython, is that JPython uses Java bytecodes, not Python bytecodes. ZPublisher and DTML both use these reflection * ExtensionClasses: ZPublisher and DTML are the only parts of Zope that can work without ExtensionClasses (and DTML performance suffers without the MultiMapping extension). ExtensionClasses are C-based Python types which override object behaviors in ways that Python objects cannot. This means that porting them to JPython means altering the JPython Java skeletons - which will require good understanding of JPython internals, as well as an *extremely* good understanding of the intent of the original C implementation. * Persistence and synchronization: Zope object persistence and synchronization are implemented via ExtensionClasses, and involve further magic that will require very good understanding of the JPython skeletons as well as the current C implementation for Zope. * Acquisition: Actually, not as difficult, compared to ExtensionClasses as a whole and persistence in particular, but it's still ExtensionClass based and probably a fair bit of work to do right. In short, if you want a "JZope", you're going to have to work mighty hard for it. Or... if Pythons 1.6 through 2.0 move the ExtensionClass machinery, or something like it, into the base definition of Python.. AND the JPython folks follow suit... AND Digital Creations moves to the new "standard" extension machinery, THEN... a JPython port might be (somewhat) more "reasonable." I thought the idea was pretty cool myself a while back, until I started thinking about what it would actually take. IMHO, it's too much work just to get one extra buzzword added to Zope's already extensive collection of them. :)
Awesome post. Thanks. And ouch. Sounds like heavy lifting. That bytecode stuff sounds sticky (hadn't even heard of that low a level of stuff before). I still think its an obvious win, but I can see where it may just be way hard. Something (for me) to strive for as I come up to speed with Zope. Thanks for the survey Phillip, = Joe = "Phillip J. Eby" wrote:
At 08:06 PM 11/2/99 -0800, Joe Grace wrote:
Finally, on a coder side, there's been some discussion on this topic before. DC has reflected on the subject and pointed out some non-trivialities of porting to Java (mainly (?) C code). I imagine it's non-trivial, but getting something running might be reasonable.
Actually, no, it isn't. The only part of Zope which might be 'reasonable' is the ZPublisher bit, and even it makes heavy use of reflection (see below). Here are just a few of the things I'm aware of:
* Reflection: Zope makes heavy use of Python internals, such as function metadata and examination of bytecodes used in Python expressions. These are not available in JPython, and it's not even a C issue, just a Python implementation issue. One reason some of these items don't exist in JPython, is that JPython uses Java bytecodes, not Python bytecodes. ZPublisher and DTML both use these reflection
* ExtensionClasses: ZPublisher and DTML are the only parts of Zope that can work without ExtensionClasses (and DTML performance suffers without the MultiMapping extension). ExtensionClasses are C-based Python types which override object behaviors in ways that Python objects cannot. This means that porting them to JPython means altering the JPython Java skeletons - which will require good understanding of JPython internals, as well as an *extremely* good understanding of the intent of the original C implementation.
* Persistence and synchronization: Zope object persistence and synchronization are implemented via ExtensionClasses, and involve further magic that will require very good understanding of the JPython skeletons as well as the current C implementation for Zope.
* Acquisition: Actually, not as difficult, compared to ExtensionClasses as a whole and persistence in particular, but it's still ExtensionClass based and probably a fair bit of work to do right.
In short, if you want a "JZope", you're going to have to work mighty hard for it. Or... if Pythons 1.6 through 2.0 move the ExtensionClass machinery, or something like it, into the base definition of Python.. AND the JPython folks follow suit... AND Digital Creations moves to the new "standard" extension machinery, THEN... a JPython port might be (somewhat) more "reasonable."
I thought the idea was pretty cool myself a while back, until I started thinking about what it would actually take. IMHO, it's too much work just to get one extra buzzword added to Zope's already extensive collection of them. :)
At 12:12 PM 11/3/99 -0800, Joe Grace wrote:
Awesome post. Thanks. And ouch.
Sounds like heavy lifting. That bytecode stuff sounds sticky (hadn't even heard of that low a level of stuff before). I still think its an obvious win, but I can see where it may just be way hard.
Some easier wins might be to: * Make a Java servlet that can funnel requests to Zope via PCGI or FastCGI * Make a Zope Product that can run servlets or other Java classes via JNI (there already exist some C-based interfaces to Java from Python) These could provide the desired Java interoperability without requiring a rewrite of Zope proper. Sure, it's not "100% Java", but as somebody else has pointed out, CPython can run pretty much anywhere Java can anyhow.
"PJE" == Phillip J Eby <pje@telecommunity.com> writes:
PJE> * Reflection: Zope makes heavy use of Python internals, such PJE> as function metadata Newer versions of JPython have a lot of the reflection attributes expected from CPython objects. Not all of course, and I don't know what Zope requires, but e.g. func_code, func_globals, func_defaults are all readable. Some reflection attrs that are writable in CPython may not be writable in JPython. I'd be interested to know what Zope requires here. PJE> and examination of bytecodes used in PJE> Python expressions. Okay, that's a tricky one :) PJE> * ExtensionClasses: ZPublisher and DTML are the only parts of PJE> Zope that can work without ExtensionClasses (and DTML PJE> performance suffers without the MultiMapping extension). PJE> ExtensionClasses are C-based Python types which override PJE> object behaviors in ways that Python objects cannot. It actually might not be hard to "port" or re-implement ExtensionClasses to JPython, esp. because you've got a real OOP underneath. It might be as easy as deriving from PyObject, implement the behavior you want, and then exporting this into Python as a class that can be derived from. PJE> * Acquisition: Actually, not as difficult, compared to PJE> ExtensionClasses as a whole and persistence in particular, PJE> but it's still ExtensionClass based and probably a fair bit PJE> of work to do right. I talked about this in a previous post. PJE> In short, if you want a "JZope", you're going to have to work PJE> mighty hard for it. Or... if Pythons 1.6 through 2.0 move PJE> the ExtensionClass machinery, or something like it, into the PJE> base definition of Python.. AND the JPython folks follow PJE> suit... AND Digital Creations moves to the new "standard" PJE> extension machinery, THEN... a JPython port might be PJE> (somewhat) more "reasonable." It would be a very useful discussion to have. I'd like to see much more convergence in the reflection and extension areas of the two implementations. -Barry
At 01:44 PM 11/4/99 -0500, Barry A. Warsaw wrote:
"PJE" == Phillip J Eby <pje@telecommunity.com> writes:
PJE> * Reflection: Zope makes heavy use of Python internals, such PJE> as function metadata
Newer versions of JPython have a lot of the reflection attributes expected from CPython objects. Not all of course, and I don't know what Zope requires, but e.g. func_code, func_globals, func_defaults are all readable. Some reflection attrs that are writable in CPython may not be writable in JPython. I'd be interested to know what Zope requires here.
Check out ZPublisher's "mapply.py" for what ZPublisher needs. Basically, it needs argument names in addition to the above, which if I recall from JPython's docs is not currently available (i.e. co_varnames).
PJE> and examination of bytecodes used in PJE> Python expressions.
Okay, that's a tricky one :)
Yep. The DTML "expr" logic scans Python bytecodes looking for ones which access a variable name, then looks them up in co_varnames to get the name. The purpose is so that names referenced in a Python expression can be "hotwired" into a locals() dictionary when the expression is executed. This is necessary because CPython can't deal with the locals() part of an eval/exec being anything other than a 'pure' C dictionary object. If JPython doesn't have this requirement for eval/exec, a workaround may be possible. I think there may be other bytecode hacking done in the DTML classes done for security purposes, but I don't recall off the top of my head.
PJE> * ExtensionClasses: ZPublisher and DTML are the only parts of PJE> Zope that can work without ExtensionClasses (and DTML PJE> performance suffers without the MultiMapping extension). PJE> ExtensionClasses are C-based Python types which override PJE> object behaviors in ways that Python objects cannot.
It actually might not be hard to "port" or re-implement ExtensionClasses to JPython, esp. because you've got a real OOP underneath. It might be as easy as deriving from PyObject, implement the behavior you want, and then exporting this into Python as a class that can be derived from.
I didn't say it was impossible, just that you need to deeply grok both systems. I'm one of (I believe) relatively few people outside DC who claim even moderate grokking of ExtensionClasses, so that would seem to imply that the potential number of people who could implement a port correctly pretty small. (Especially since I don't even have a rudimentary grokking of how JPython's underlying shells work.) Here are the things a JExtensionClasses would have to do, that I know of: * Implement the __of__ hook (from what you've said, this probably isn't excessively difficult) * Implement the __call_method__ hook (requires __of__, plus a "PythonMethod" helper class) * Impliment inherited_attribute (or whatever the exact name is) * Implement __class_init__ (called when an ExtensionClass subclass' class/type object is first created) * Allow hooking __getattr__ at a level above the level which is normally allowed by Python (i.e., *before* the instance or class dictionaries are searched) Hmmm. Y'know, now that I'm really thinking this through step by step... it doesn't look quite as impossible as it first appeared. However, my first reaction to that thought is that it probably just means my grok of ExtensionClasses themselves isn't as good as I think. :) Mainly though, it's occurring to me that a lot of the deepest voodoo I know of in ExtensionClasses has to do with making C subclassable in C or Python, and keeping track of reference counts. Since JPython already makes the underlying language subclassable, and doesn't *need* reference counts... Hm.
It would be a very useful discussion to have. I'd like to see much more convergence in the reflection and extension areas of the two implementations.
The interesting bit seems to be this: if the truly hard work of ExtensionClasses has already implicitly been done in JPython, it might make it more reasonable for somebody with a deep JPython knowledge to worm the necessary remaining ExtensionClass knowledge out of the DC folks or persons like myself. My interest in the project is rather limited, in that Java's not a buzzword I currently need for any of my work. But if it's doable, it'd be an interesting curiosity. Of course, once Zope itself is up, there are still things like intSet and BTree that have to be converted from C, as well as the cOptimizations, cPickleCache, etc. Which I expect will all have challenges of their own. In other words, "the devil is in the details."
At 13:06 03/11/99 -0500, Phillip J. Eby wrote:
* ExtensionClasses: ZPublisher and DTML are the only parts of Zope that can work without ExtensionClasses (and DTML performance suffers without the MultiMapping extension).
This is encouraging! We've been thinking about porting just the DTML module to Java. We have a large client who is committed to Java Servlets for most of their transactional applications, but have deployed Zope for part of their editorial content. We have been studying the feasibility of porting DTML either to JPython or to Java directly. We believe DTML is a very smart approach do HMTL server-side scripting, and making it available on the Java platform could convert more people to Zope in the long run. Is anyone else interested in taking part in such an effort? Best regards, Luciano Ramalho
participants (8)
-
Barry A. Warsaw -
Hannu Krosing -
Joe Grace -
Luciano Ramalho -
Martijn Pieters -
Patrick Phalen -
Phillip J. Eby -
smoerk@gmx.de