项目collective.portlet.localcumulus cumulus product by makina corpus

collective.portlet.localcumulus的Python项目详细描述


Introduction

这个包提供了两个新的基于tagcloud的portlet

使用

  • cache (refresh)
  • local path searches enhancements

对于“自定义portlet”:

  • url customization for tag browsing

用法

  • Install “Local Tag cloud (cumulus) portlet” with QuickInstaller.
  • Select Local Tag Cloud (cumulus) portlet from Add portlet drop-down menu.
  • Provide your own values for portlet configuration if needed.
  • Save changes.

支持的plone版本

  • 3.x

存储库:

svn

collective.portlet.cumulus Installation

要将collective.portlet.cumulus安装到全局python环境(或workingenv)中, 使用传统的zope 2实例,您可以这样做:

  • When you’re reading this you have probably already run

    ``easy_install collective.portlet.cumulus``.
    

    Find out how to install setuptools (and EasyInstall) here: http://peak.telecommunity.com/DevCenter/EasyInstall

  • If you are using Zope 2.9 (not 2.10), get pythonproducts and install it via:

    python setup.py install --home /path/to/instance
    

    into your Zope instance.

  • Create a file called ^{tt1}$ in the ^{tt2}$ directory. The file should only contain this:

    <include package="collective.portlet.cumulus" />
    

或者,如果您使用的是zc.buildout和plone.recipe.zope2instance 配方管理您的项目,您可以这样做:

  • Add ^{tt3}$ to the list of eggs to install, e.g.:

    [buildout]
    ...
    eggs =
        ...
        collective.portlet.cumulus
    
  • Tell the plone.recipe.zope2instance recipe to install a ZCML slug:

    [instance]
    recipe = plone.recipe.zope2instance
    ...
    zcml =
        collective.portlet.cumulus
    
  • Re-run buildout, e.g. with:

    $ ./bin/buildout
    

如果要显式地包含包,可以跳过zcml slug 从另一个包的configure.zcml文件。

Detailed documentation

The local renderer and portlet objects

为测试搜索添加一些内容

>>> self.setRoles(('Manager', ))
>>> self.portal['front-page'].edit(subject=['global', 'tags'])
>>> if1 = self.folder.invokeFactory('Folder', id='f1')
>>> if2 = self.folder.invokeFactory('Folder', id='f2')
>>> f1 = self.folder[if1]
>>> f2 = self.folder[if2]
>>> d1 = f1.invokeFactory('Document', id='blog-entry1')
>>> d2 = f1.invokeFactory('Document', id='blog-entry2')
>>> d3 = f2.invokeFactory('Document', id='blog-entry3')
>>> d4 = f2.invokeFactory('Document', id='blog-entry4')
>>> f1[d1].edit(subject=['blog', 'tags'])
>>> f1[d2].edit(subject=['foo', 'bar'])
>>> f2[d3].edit(subject=['toto', 'titi'])
>>> f2[d4].edit(subject=['toto', 'tutu'])

正在寻找合适的适配器

>>> from collective.portlet.localcumulus.interfaces import ILocalTagsRetriever
>>> from collective.portlet.localcumulus import catalog
>>> data = catalog.DummyData()
>>> data.refreshInterval = 1

此适配器将上下文和分类作为“data”属性

>>> retriever = ILocalTagsRetriever(f1)
>>> retriever
<collective.portlet.localcumulus.catalog.LocalTags object at ...>

尝试获取f1文件夹的本地标记

>>> data.path = '/'.join(f1.getPhysicalPath())
>>> retriever.data = data
>>> print '\n'.join(['%s %s %s'% i for i in retriever.getTags()])
blog 1 http://nohost/plone/search?path=/plone/Members/test_user_1_/f1&Subject:list=blog
foo 1 http://nohost/plone/search?path=/plone/Members/test_user_1_/f1&Subject:list=foo
bar 1 http://nohost/plone/search?path=/plone/Members/test_user_1_/f1&Subject:list=bar
tags 1 http://nohost/plone/search?path=/plone/Members/test_user_1_/f1&Subject:list=tags

尝试获取f2文件夹的本地标记

>>> data.path = '/'.join(f2.getPhysicalPath())
>>> print '\n'.join(['%s %s %s'% i for i in retriever.getTags()])
tutu 1 http://nohost/plone/search?path=/plone/Members/test_user_1_/f2&Subject:list=tutu
titi 1 http://nohost/plone/search?path=/plone/Members/test_user_1_/f2&Subject:list=titi
toto 2 http://nohost/plone/search?path=/plone/Members/test_user_1_/f2&Subject:list=toto

如果我们有一个没有路径的portlet,它将在系统范围内运行

>>> data.path = ''
>>> print '\n'.join(['%s %s %s'% i for i in retriever.getTags(data=data)])
bar 1 http://nohost/plone/search?Subject:list=bar
blog 1 http://nohost/plone/search?Subject:list=blog
foo 1 http://nohost/plone/search?Subject:list=foo
global 1 http://nohost/plone/search?Subject:list=global
tags 2 http://nohost/plone/search?Subject:list=tags
titi 1 http://nohost/plone/search?Subject:list=titi
toto 2 http://nohost/plone/search?Subject:list=toto
tutu 1 http://nohost/plone/search?Subject:list=tutu

测试缓存

>>> import time
>>> data.path = '/'.join(f2.getPhysicalPath())
>>> data.refreshInterval = 10
>>> [o[0] for o in retriever.getTags()]
[u'tutu', u'titi', u'toto']
>>> f2[d4].edit(subject=['toto', 'tutu', 'tata'])
>>> [o[0] for o in retriever.getTags()]
[u'tutu', u'titi', u'toto']
>>> time.sleep(2)
>>> [o[0] for o in retriever.getTags()]
[u'tutu', u'titi', u'toto']

11秒后,缓存寿命将上升

>>> time.sleep(9)
>>> [o[0] for o in retriever.getTags()]
[u'tutu', u'titi', u'toto', u'tata']

The local custom portlet

自定义portlet允许用户格式化用于浏览标记的url,而不是使用plonesearch_form作为默认值。

Tests

为测试搜索添加一些内容

>>> self.setRoles(('Manager', ))
>>> self.portal['front-page'].edit(subject=['global', 'tags'])
>>> if1 = self.folder.invokeFactory('Folder', id='f1')
>>> if2 = self.folder.invokeFactory('Folder', id='f2')
>>> f1 = self.folder[if1]
>>> f2 = self.folder[if2]
>>> d1 = f1.invokeFactory('Document', id='blog-entry1')
>>> d2 = f1.invokeFactory('Document', id='blog-entry2')
>>> d3 = f2.invokeFactory('Document', id='blog-entry3')
>>> d4 = f2.invokeFactory('Document', id='blog-entry4')
>>> f1[d1].edit(subject=['blog', 'tags'])
>>> f1[d2].edit(subject=['foo', 'bar'])
>>> f2[d3].edit(subject=['toto', 'titi'])
>>> f2[d4].edit(subject=['toto', 'tutu'])

正在寻找合适的适配器

>>> from collective.portlet.localcumulus.interfaces import ICustomLocalTagsRetriever
>>> from collective.portlet.localcumulus import catalog
>>> data = catalog.DummyData()
>>> data.refreshInterval = 1
>>> data.path = '/'.join(f1.getPhysicalPath())

此适配器将上下文和分类作为“data”属性

>>> retriever = ICustomLocalTagsRetriever(f1)
>>> retriever
<collective.portlet.localcumulus.catalog.CustomLocalTags object at ...>

尝试获取没有url的f1文件夹的本地标记时,它将默认为localtag行为

>>> data.search_url = ''
>>> retriever.data = data
>>> print '\n'.join(['%s %s %s'% i for i in retriever.getTags()])
blog 1 http://nohost/plone/search?path=/plone/Members/test_user_1_/f1&Subject:list=blog
foo 1 http://nohost/plone/search?path=/plone/Members/test_user_1_/f1&Subject:list=foo
bar 1 http://nohost/plone/search?path=/plone/Members/test_user_1_/f1&Subject:list=bar
tags 1 http://nohost/plone/search?path=/plone/Members/test_user_1_/f1&Subject:list=tags

Customize url with variables

我们可以用python dict string格式处理一些变量。

如果我们的url中没有任何参数,它只会在末尾附加标记

>>> [bool(catalog.NOT_SIMPLE_URL_RE.match(a)) for a in ['azerty', '()', '%(azerty)s', '%()', '%()s']]
[False, False, True, False, False]
>>> data.search_url = 'http://foo'
>>> retriever.data = data
>>> print '\n'.join(['%s' % i for i in retriever.getTags()])
[u'blog', 1, u'http://foo/blog&path=/plone/Members/test_user_1_/f1']
[u'foo', 1, u'http://foo/foo&path=/plone/Members/test_user_1_/f1']
[u'bar', 1, u'http://foo/bar&path=/plone/Members/test_user_1_/f1']
[u'tags', 1, u'http://foo/tags&path=/plone/Members/test_user_1_/f1']

您肯定需要在url中的某个位置至少添加%(tag)s才能包含标记信息;)。

可用的变量有:

  • portal_path: plone site path
  • portal_url: plone site url
  • here_url: context url
  • here_path: context path inside the ZODB
  • tag: the tag
  • tag_weight: weight of the tag
>>> data.search_url = '%(portal_url)s?path=%(portal_path)s&url=%(here_url)s&hpath=%(here_path)s&tag=%(tag)s&weight=%(tag_weight)s'
>>> retriever.data = data
>>> print '\n'.join(['%s' % i for i in retriever.getTags()])
[u'blog', 1, u'http://nohost/plone?path=/plone&url=http://nohost/plone/Members/test_user_1_/f1&hpath=/plone&tag=blog&weight=1']
[u'foo', 1, u'http://nohost/plone?path=/plone&url=http://nohost/plone/Members/test_user_1_/f1&hpath=/plone&tag=foo&weight=1']
[u'bar', 1, u'http://nohost/plone?path=/plone&url=http://nohost/plone/Members/test_user_1_/f1&hpath=/plone&tag=bar&weight=1']
[u'tags', 1, u'http://nohost/plone?path=/plone&url=http://nohost/plone/Members/test_user_1_/f1&hpath=/plone&tag=tags&weight=1']

Changelog

1.5 - 2010-03-16

  • 错误修复:自定义portlet中的路径[kiorky]

1.4 - 2010-03-16

  • grok fix(删除,无用)[kiorky]
  • 修复测试。

1.3 - Unreleased

  • 自定义portlet中的荣誉路径[kiorky]

1.2 - 2010-02-08

  • 添加带有特殊URL的可定制Portlet,以便在选择标记时进行浏览[Kiorky]

1.0 - 2010-01-18

  • 初始版本[Kiorky]

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java是否在servlet中检索上一页路径?   Java抱怨在开关的默认情况下未初始化最终字段   Java泛型:为什么编译器不能判断这个类<t>对象与这个类的类型参数的对象的类具有相同的类型?   Java:继承方法中使用的私有变量   HibernateJava。ClassCastException:java。lang.Integer不能强制转换为abc。def。我的项目。奥姆。EmployeeTopMetaData   http java发布和下载文件   java改进条件检查   java如何将2d数组的条目作为键放在地图中   java如何获取传递给运行时的值。getRuntime。JUnit测试用例中的exit(value)   java注释来创建所有可能的构造函数   自动建议列表:java。lang.IllegalArgumentException:在XPath表达式为null时找不到元素   为什么MapAPI在Java中不提供流功能?   gradle不导入本地java库   尽管我使用的是SessionCreationPolicy,java Spring安全性似乎仍在使用会话。无国籍   使用java查找MongoDB中数组元素的平均值