JSONView is now available as part of the jsonserver package.
A JSONView responds to HTTP GET and returns a snippet of JSON. This is
useful for AJAX/XHR, things like repopulating a select list without a
full page refresh.
Usage is fairly simple. Make a view class subclassing JSONView from
jsonserver. In your view class, make a method, doResponse, that returns
a python dict or list that is the data you wish to return to the
client. One other method is always called before publication,
doCacheControl, which may be overridden/extended for setting caching
headers. Content-type, which is by default 'application/json', may be
overridden in your class by setting an instance variable named
contentType. Register your view with the <browser:page> ZCML directive,
giving it a name, for (interface), class, and permission.
JSONView takes care of matching named parameters in the request with
named parameters in the doResponse method, so a view named "sum" with a
method signature like doResponse(a,b=10) can be requested like http://x
ample.com/sum?a=4&b=9
jsonserver with JSONViews is available (ATM) only on z3labs svn:
http://codespeak.net/svn/z3/jsonserver/trunk
For more information the README (ftest) is at
http://codespeak.net/svn/z3/jsonserver/trunk/JSONViews.txt .
This is new code, so comments/suggestions are welcome.
-Jim Washington
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users