Plone-如何在事件订阅服务器中设置DefaultPage?

Plone-如何在事件订阅服务器中设置DefaultPage?,plone,dexterity,plone-4.x,Plone,Dexterity,Plone 4.x,我有一个folderish灵巧内容类型和一个事件订阅者。创建内容类型时,我创建了一个集合,它根据几个参数显示容器中的子级。创建集合后,我尝试将容器的默认页面设置为集合 def myContainerAdded(my_container, event): #get container #set advanced query for collection #create collection with api.create my_container.setDefaul

我有一个folderish灵巧内容类型和一个事件订阅者。创建内容类型时,我创建了一个集合,它根据几个参数显示容器中的子级。创建集合后,我尝试将容器的默认页面设置为集合

def myContainerAdded(my_container, event):
    #get container
    #set advanced query for collection
    #create collection with api.create
    my_container.setDefaultPage(new_collection.id)
configure.zcml中的订阅服务器

<subscriber
  for="my.product.my_container.IMyContainer
       zope.lifecycleevent.interfaces.IObjectAddedEvent" 
  handler=".events.myContainerAdded" />
编辑: 我发现了一些有趣的东西。我临时注释掉了事件订阅服务器中与集合相关的代码。我手动将集合添加到容器对象,然后将容器的默认页面设置为集合。容器的默认页面是集合

def myContainerAdded(my_container, event):
    #get container
    #set advanced query for collection
    #create collection with api.create
    my_container.setDefaultPage(new_collection.id)

也许有些东西没有被正确地索引?

事实上一切都进行得很顺利,只是在创建了基于灵巧性的内容类型之后,一个内容类型将到达默认视图的URL,这意味着“/view”被附加到项目的URL,这是默认视图方法的别名,这里解析为“folder\u listing”(文件夹列表)模板

要快速解决此问题,您可以在订阅服务器的方法中添加重定向到对象的URL,而无需将任何视图名称附加到URL:

event.REQUEST.RESPONSE.redirect(my_container.absolute_url())

我应该在第一次创建对象时注意到/view部分。实际上,导航也指向了正确的页面。感谢您发布的解决方案。我很感激。我也花了一两分钟才认出它来。这也是一个错误,伊莫。谢谢你问这个问题,我正在做一些相关的事情,你的任务在正确的时间带来了正确的想法:-)如果你想搜索,如果一个bug报告已经存在或报告一个,请在这里留下一个链接到罚单(GitHub上的问题)。希望你周一有一个丰收日!