未来内容的控制访问 [英] Control access on future content

查看:105
本文介绍了未来内容的控制访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这主要是关于定时对未来的公开内容,但不是唯一的。

this is mostly about public content timed on the future, but not only.

在一个标准的Plone网站,如果你创建一个顶级内容并不在导航显示(仍然是私有的),那么你把它公开(通过工作流程),它显示了在导航,但后来你火候在未来,它再次从导航消失。

In a standard Plone site if you create a top-level content is not shown on the navigation (is still private), then you make it public (via workflow) and it shows up on the navigation, but later you time it in the future and again it disappears from the navigation.

不过,在这一点上,如果一个匿名/登录的用户知道该URL,他们将能够看到内容

Still, at that point, if an anonymous/logged-in user knows the URL they will be able to see the content.

在我们的例子中,一份报纸,我们不仅有(内容定时未来),但我们也有这就需要或者没有看到的内容(付费用户/ premium用户不同的用户角色...)。

In our case, a newspaper, we not only have that (content timed to the future) but we also have different roles of users which need or don't have to see that content (paid subscribers/premium users...).

检查查看许可,即

security = getSecurityManager()
if security.checkPermission('View', obj):
   # user can see the object

是远远不够的。

检查查看权限,如果内容是在未来,即

Check for view permission and if the content is in the future, i.e.

security = getSecurityManager()
if security.checkPermission('View', obj) and \
        not object.effective_date.isFuture():
   # user can see the object

又是因为有些用户需要看到未来的内容(即内容编辑器),而普通用户不能和关于premium用户的顶部应办看到他们不够的,所以像这样实际上会做的事:

again is not enough as some users do need to see future content (i.e. content editors) while normal users should not and on top of that premium users should do see them, so something like this would actually do:

security = getSecurityManager()
if security.checkPermission('View', obj) and \
        (not object.effective_date.isFuture() or 
         security.checkPermission('Can see future content', obj):
   # user can see the object

但随后的问题是:因为这在整个网站中使用(铅页面,文章,交联,导航,搜索......)这感觉不对,是相当繁琐不得不重复所有这种检查各地随处可见。

But the question then is: as this has to be used throughout the website (lead pages, articles, cross-linking, navigation, searches...) it doesn't feel right and is quite tedious to have to repeat all this checks all over everywhere.

是否有关于如何解决这个任何其他的方法呢?

Is there any other approach on how to solve this?

推荐答案

有一个插件产品,不正是你所需要的:

there is an addon product that does exactly what you need:

collective.wfeffectiverange

collective.wfeffectiverange

它的工作原理是增加一个定时任务查找尚未公布的(今后有效日期)或过期(到期日到达)内容,并在这种情况下应用的工作​​流程过渡

it works by adding a cron job that looks for not yet published (effective date in the future) or expired (expiration date reached) content and apply a workflow transition in this case.

请参见 https://pypi.python.org/pypi/collective.wfeffectiverange 了解更多信息。

这篇关于未来内容的控制访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆