Lennart Regebro wrote:
On 5/24/06, Pascal Peregrina <Pperegrina@lastminute.com> wrote:
By Zope objects I meant:
You've got a page template for example, and you include such an "AJAX enabled object", basically rendering an HTML fragment, and the resulting page will include the page template code + the fragment (similar to a macro call), but will also include the needed javascript code to handle the asynchronous communication.
That is a macro call. There is no difference. It just that the macro includes the HTML needed to suck in the JS library you use. I have been working on a simple WSGI middleware filter that handles js library insertion pretty well, without complicated macros that assure that a javascript library gets included only once.
It works by creating a WSGI environ variable for desired includes. Individual widgets ask a utility to register their need for a particular javascript or css resource into that environ variable. After Zope is finished generating the page, the middleware inserts the appropriate <script> and/or <style> tags into <head> before delivery to the client. The current implementation works in Zope 3. I have not experimented with Zope 2 on this, but it seems that with Zope 2's new WSGI-friendliness and Five, it is likely not too far from something usable in Zope 2. The Zope 3 implementation needs zope.paste and paste.deploy. The middleware app itself should work for anything WSGI. Code (Due credit: the Zope 3 infrastructure for this borrows heavily from zc.resourcelibrary) and instructions are at http://zif.hill-street.net/headincludes Development status: "works for me". This is just a small piece of the AJAX puzzle for Zope, as I see it. -Jim Washington