This is mostly a convenience package that configures a <resourceDirectory> for using dojo with Zope 3. It also provides Zope 3 infrastructure for using dojo's json-rpc client.
Unzip this package somewhere on the Python Path. [zope3 instance]/lib/python is a good choice.
Get a Dojo distribution from http://download.dojotoolkit.org/ and unpack it into this folder. You must rename the folder or symlink it so that the main dojo folder is called "dojo". The folder structure should look like:
[this folder] -> [dojo] -> dojo.js, [src], etc.
Copy the dojosupport-configure.zcml file to [zope3 instance]/etc/package-includes.
Zope 3 will sometimes assign an incorrect content-type for these files. This will cause occasional problems when dojo's parser depends on the content-type for parsing decisions. Mainly, if "<html>" is not early enough in a file, Zope 3 will not recognize the file as html and mark it as text/plain.
A work-around for this, presuming that Zope 3's behavior is intended, is to use another means to make dojo's files available.
One such method involves the WSGI capabilities of Zope 3/Twisted.
Sample etc/paste.ini file:
[pipeline:zope] pipeline = gzipper main [composite:Paste.Main] use = egg:Paste#urlmap / = zope /@@/dojo = dojo [app:main] paste.app_factory = zope.paste.application:zope_publisher_app_factory [app:dojo] use=egg:Paste#static document_root=/path/to/dojo/directory filter-with = gzipper [filter:gzipper] paste.filter_factory=gzipper.gzipper:filter_factory nocompress=jp gz zip tempfile=0 # exclude=src #[filter:printdebug] #use=egg:Paste#printdebug #[filter:lint] #use=egg:Paste#lint
Include the following in the <head> section of your html document.
<script type="text/javascript" src="/@@/dojo/dojo.js"></script>
If jsonserver is installed, dojosupport provides a view called "jsonrpc.smd" for any traversable object. This provides a JSON-formatted breakdown of JSON-RPC methods available for that object.
This makes it possible to instanciate a json-rpc proxy in Dojo with the following javascript statements:
dojo.require("dojo.rpc.JsonService");
var proxy = new dojo.rpc.JsonService("jsonrpc.smd");