[Zope] Best Practice for including Javascript in Zope Applications

Matt Hollingsworth mr.hworth at gmail.com
Wed Jan 2 15:53:13 EST 2008

Yep!  I have had very good luck with it so far; my little hack that I posted
works like a (klutzy) charm and ExtJS is great with zope.  The ExtJS folks
are very well organized, and the library is quite powerful.  It's working
great.  However, my application doesn't have quite the segregation that
yours does; ExtJS and zope (DTML in particular) are much more intermingled,
and can't be easily separated.  This application is actually a frontend for
a Java library that controls instruments at CERN (a research lab I work
for), and I love the solution that it has presented.  It works like a charm.
(in case you're curious, it makes use of a wonderful python library I ran
across called JPype (http://jpype.sourceforge.net) to execute the Java code)

I am going to be accessing Zope through apache with the VHM, but there are
multiple reasons why I don't want to serve the js through apache.  This same
principle is the reason that I don't want to upload things through FTP or
WebDAV.  I'm making a product, and I would like to keep it atomic, i.e., I
want the only install procedure to be "copy product folder to
instance/Products".  Uploading via WebDAV, or hosting the javascript using
separate software, defeats that purpose.  

The solution that Tom proposed (LocalFS) seems to be what I want, but the
problem is that I think it is way too out of date; it crashed my zope server
(2.10.5) when I installed it.  It says nothing can be found after I add an
instance through the ZMI, and this is after I fixed a deprecated import (
from OFS.content_types import find_binary -> from zope.app.content_types
import find binary).  I had to completely remove the product to get my Zope
instance to work again.  

I'm getting the feeling that there isn't really a (recent) canned solution
for accessing file system content, which is... strange at best, considering
all the power that zope has at its disposal.  You would think that accessing
the file system would be present just because it is so simple to do.  I'm
not complaining, as I'm *very* happy with zope, I'm just surprised :).  I
realize that zope's principle is to store everything in the database, but
this is unacceptable for content such as video files, right?  I mean the
ZODB file would be absolutely humongous (and slow?  I don't know for sure
how it's implemented).

If there isn't already a working solution, I would be happy to come up with
one; I could just hack out the parts of LocalFS that work, add a few
features, and repackage it into a new product.  It's not difficult to do (my
little trivial solution already would work fine if I did a non-dumb
implementation of the file-serving logic), and as much as I would like to
use it for other projects, it would be worth my time.  For example, I want
to make a little video/music server as a personal project unrelated to my
current one, and I really don't want to store things in the ZODB if I can
help it... 1 video = +1 gig ZODB? :S

I don't know much about zope obviously, so if I get some vehement objections
to this route, I'll pick another :)



-----Original Message-----
From: Tim Nash [mailto:thedagdae at gmail.com] 
Sent: Wednesday, January 02, 2008 2:03 PM
To: Tom Von Lahndorff
Cc: Matt Hollingsworth; zope at zope.org
Subject: Re: [Zope] Best Practice for including Javascript in Zope

I am writing an application that uses extjs as the front end and zope
on the back and they work together really well.
I am using a webserver to server the extjs library and everything else
comes out of zope.  So far I have had no trouble with relative links
or files broken up in different locations. It may be because I have
fully committed to having an extjs front end. I typically serve a page
out of zope, it calls the extjs library as well as custom JavaScript
files. The web2.0 style page then makes multiple xhr calls back to
zope to load smaller html and json fragments. Works like a charm and
has the additional benefit of letting me cache the majority of the
front end in the webserver and in the users browser.

Have fun because you have just come across a wonderful
combination...extjs and zope!

On Jan 2, 2008 6:38 AM, Tom Von Lahndorff <tom at modscape.com> wrote:
> On Jan 1, 2008, at 7:20 PM, Matt Hollingsworth wrote:
> > Hello,
> >
> > I'm new to developing for zope, and I have a quick question
> > regarding some best practices when using Javascript in zope
> > applications.
> >
> > I would like to use Ext JS (http://www.extjs.com/ ) in an
> > application that I am writing.  It is a fairly extensive library, so
> > I didn't really want to copy/paste every single file into a dtml
> > method.  I looked all over the place for some discussion on this
> > subject, but only found things relating to plone (which apparently
> > has a javascript registry); however, I wish to stay away from plone
> > for this particular application.
> >
> > What should I do to use these libraries?  Is there a canned solution
> > for this sort of thing?
> >
> > Thank you much!
> >
> > -Matt
> > _______________________________________________
> > Zope maillist  -  Zope at zope.org
> > http://mail.zope.org/mailman/listinfo/zope
> > **   No cross posts or HTML encoding!  **
> > (Related lists -
> > http://mail.zope.org/mailman/listinfo/zope-announce
> > http://mail.zope.org/mailman/listinfo/zope-dev )
> You can ftp the files to a "static" directory on the file system and
> use LocalFS to access them.
> Zope maillist  -  Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )

More information about the Zope mailing list