zope3的json-rpc项目树
z3c.jsontree的Python项目详细描述
这个包为zope3提供了一个json-rpc项目树实现。
详细文档
jsonrpc树
这个包提供了一个jsonrpc树视图,可以用作导航树。 让我们演示如何注册jsonrpc树视图:
>>> from zope.configuration import xmlconfig >>> import z3c.jsonrpc >>> context = xmlconfig.file('meta.zcml', z3c.jsonrpc) >>> context = xmlconfig.string(""" ... <configure ... xmlns:z3c="http://namespaces.zope.org/z3c"> ... <z3c:jsonrpc ... for="*" ... class="z3c.jsontree.jsonrpc.JSONTreeItems" ... permission="zope.Public" ... methods="loadJSONTreeItems" ... layer="z3c.jsonrpc.testing.IJSONRPCTestSkin" ... /> ... </configure> ... """, context)
现在,我们将基于默认的zope文件夹类设置一些内容结构:
>>> from zope.site.folder import Folder >>> site = getRootFolder() >>> content = Folder() >>> site['content'] = content
我们需要能够获得表单的绝对url:
>>> import zope.interface >>> import zope.component >>> from zope.location.interfaces import ILocation >>> from zope.traversing.browser.interfaces import IAbsoluteURL >>> class FakeURL(object): ... zope.interface.implements(IAbsoluteURL) ... zope.component.adapts(ILocation, zope.interface.Interface) ... def __init__(self, context, request): ... pass ... def __str__(self): ... return u'http://fake/url' ... def __call__(self): ... return str(self)>>> zope.component.provideAdapter(FakeURL)
json-rpc代理
如果调用json-rpc树项方法,我们可以看到不同的json数据 关于不同的上下文:
>>> from z3c.jsonrpc.testing import JSONRPCTestProxy >>> siteURL = 'http://localhost/++skin++JSONRPCTestSkin' >>> proxy = JSONRPCTestProxy(siteURL) >>> proxy.loadJSONTreeItems('z3cJSONTree') {u'treeChilds': {u'childs': [{u'hasChilds': False, u'contextURL': u'http://fake/url', u'url': u'http://fake/url/@@SelectedManagementView.html', u'linkHandler': u'', u'content': u'content', u'iconURL': u'', u'id': u'z3cJSONTree.::content'}], u'id': u'z3cJSONTree'}}
content对象没有项,返回一些空的json数据:
>>> proxy = JSONRPCTestProxy(siteURL + '/content') >>> proxy.loadJSONTreeItems('z3cJSONTree') {u'treeChilds': {u'childs': [], u'id': u'z3cJSONTree'}}
变化
0.6.0(2010-09-23)
- 反映zope包中的更改,使用新的外部包
- 修复损坏的测试
- 修复javacscript中的类名处理,看起来jquery的新版本 无法处理$.ClassName。has(ele,…)请改用$(ele).hasClass(…)。
- 修正:getParentsFromContextToObject,如果项 是一个代理NoStbug错误的位置。有可能 NotFound对象将包装父对象中不允许的上下文 一点链子都没有。
0.5.1(2009-03-10)
- 修复:使用从最新包导入的内容,例如zope.site.folder.folder
- 修正:聪明地处理未找到的错误对象。无法定位NotFound错误。
0.5.0(2008-04-16)
- 修正:调整ITreeitems适配器。增加了额外的鉴别器 如果使用基本注册表配置,则防止误用为/@@/适配器
- 实现了itreeitems适配器,该适配器负责列出列出的所有项 在树中
- 初始版本