跳转到主要内容

Zope3的JSON RPC项树

项目描述

此软件包为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 = 'https://127.0.0.1/++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'}}

内容对象没有项目,返回一些空JSON数据

>>> proxy = JSONRPCTestProxy(siteURL + '/content')
>>> proxy.loadJSONTreeItems('z3cJSONTree')
{u'treeChilds': {u'childs': [], u'id': u'z3cJSONTree'}}

变更记录

0.6.0 (2010-09-23)

  • 反映zope软件包中的变化,使用新的外部包

  • 修复损坏的测试

  • 修复:在javascript中处理className,新版本的JQuery无法处理$.className.has(ele, …),请使用$(ele).hasClass(…)代替。

  • 修复:getParentsFromContextToObject,如果项目是代理NotFound错误对象,则不返回父链。可能此类NotFound对象将包装一个上下文,我们在父链中根本不允许。

0.5.1 (2009-03-10)

  • 修复:使用最新包的导入,例如zope.site.folder.Folder

  • 修复:智能处理NotFound错误对象。NotFound错误不可定位。

0.5.0 (2008-04-16)

  • 修复:调整ITreeItems适配器。添加了额外的区分器,如果配置了基本注册,则可防止误用作/@@/适配器

  • 实现了负责列出树中所有项目的ITreeItems适配器

  • 初始发布

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪一个,请了解有关 安装包 的更多信息。

源代码分发

z3c.jsontree-0.6.0.tar.gz (20.8 kB 查看哈希值)

上传时间 源代码

支持者