calling javascript residing on the filesystem
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). My question, obviously, is: how can I call the js through http in the src attribute of the script tag ? Or in other words: how can i map a js file on the filesystem to an URL known to Zope ? Sorry if this question has been answered in the past, but I didn't find anything on the mailing list archives and in the other usual Zope resources. TIA, --peppo
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
participants (2)
-
Dylan Reinhardt -
Giuseppe_Bonelli____360Publishing.it