[Zope] calling javascript residing on the filesystem

Dylan Reinhardt zope@dylanreinhardt.com
Tue, 04 Feb 2003 13:33:55 -0800


At 12:02 PM 2/4/2003, Giuseppe_Bonelli____360Publishing.it wrote:
>Hi all,
>
>I am tryng to call some javascript code from a pure python product  and I 
>would like not to import into the ZOOdb the js files (they are quite a lot 
>as the js code base implements a rather complex client side app).
>
>how can i map a js file on the filesystem to an URL known to Zope ?

The first step is to recognize that there's nothing special about the fact 
that it's JavaScript.  It's just text and Zope doesn't care one bit what 
the browser intends to use the text for.

The following will allow you to provide scripts, style sheets or any other 
fixed text at a given URL from within a product:

1. Give the file a dtml extension and put it in your product folder, say as 
my_file.dtml

2. Go into your product code and associate a class attribute with that file:

---------------

from Globals import DMTLFile

class my_class(various_base_classes):
    my_interface_name = DTMLFile('my_file', Globals())

---------------

3. Refresh the product.

That's it... your file is now available at:

my_server/my_product_instance/my_interface_name

HTH

Dylan