I thought it would be useful to make note of how a couple things were done recently using Deliverance.

The first is making http://nycstreets.org/help/ point to the main openplans.org help page. This was done ad-hoc, though I’ll show how to do the equivalent in a better way with the new openplans_hooks and build.ini.

The nycsr Zope lives at localhost:12002, while openplans Zope lives at localhost:13002. When a request comes into nycsr it is generally dispatched/forwarded to http://localhost:12002/VirtualHostBase/http/nycstreets.org:80/openplans/VirtualHostRoot/PATH. That path lets Zope know how the request was originally made (so that links don’t point back to localhost:12002).

You can do ad hoc overrides with dvhoster using remote_uri.txt. Specifically we want to forward http://nycstreets.org/help/PATH to http://localhost:13001/VirtualHostBase/http/www.nycsr.com:80/openplans/VirtualHostRoot/help/PATH — note that /help goes after VirtualHostRoot. To do this we change remote_uri.txt to look like:

  [{"path": "/help",
   "remote_uri": "http://localhost:13001/VirtualHostBase/http/www.nycstreets.org:80/openplans/VirtualHostRoot/help"},
   {"path": "", "comments": "main-site"}]
  

Note that paths have to be ordered with longest path first, as the paths are matched in order (and “” matches anything). The “remote_uri” key tells dvhoster where to dispatch the request. The value ultimately goes through openplans_hooks.py which gets another try at rewriting the paths; as implemented it only does this when remote_uri isn’t set.

If you wanted to mount a project this way, you could do it like this:

  [{"path": "/bikesforbob",
     "remote_uri": "http://localhost:14001/VirtualHostBase/http/www.nycstreets.org:80/openplans/projects/VirtualHostRoot/bikesforbob"}]

Another things we did recently is to put static files up at http://dev.nycstreets.org/nymap/. The files were checked out to nymap/src/nymap, and so the remote_uri is file:///path/to/base_path/nymap/src/nymap/. In this case we used build.ini, like:

   nymap uri = file:///usr/local/topp/dev.nycstreets.org/current/nymap/src/nymap/
   nymap path = /maps
   nymap project_local = false

This is similar to the ad hoc technique:

   [{"path": "/maps",
     "remote_uri": "file:///usr/local/topp/dev.nycstreets.org/current/nymap/src/nymap"}]

“nymap project_local = false” means that this is associated with the root of the site. If it was true then /projects/PROJECTNAME/maps would be mapped instead of /maps (in a virtualhost situation /maps would be matched regardless).

This got the maps in place, but they needed access to the artois to do XMLHttpRequests, and those can’t be done across domains. So we needed to proxy artois over to dev.nycstreets.org. This was done with:

   artois_proxy uri = http://artois.openplans.org/geoserver/ows/
   artois_proxy theme = false
   artois_proxy path = /maps/rpc
   artois_proxy project_local = false

Now requests to http://nycstreets.org/maps/rpc get proxied to http://artois.openplans.org/geoserver/ows. We don’t need to theme it because it’s all API calls. Turning off theming in the configuration is slightly more efficient (though only slightly as the XMLHttpRequest calls wouldn’t ultimately have been themed anyway).

Anyway, that’s a couple techniques used recently. This sort of thing can be used to do other manipulations with the site. I’m hoping this description will get people to consider this technique when other kinds of requests come in.

Filed January 18th, 2008 under Deliverance, Architecture, OpenPlans

No Comments

RSS

No comments yet.

Leave a comment