从 Renderer 实例访问 Plone 4 portlet 的分配上下文
我想为 Plone4 制作一个上下文 portlet,然后将其添加到某些文件夹并在其各自的子文件夹中可见。然而,无论 portlet 显示在哪里,我都希望访问渲染器实例中 portlet 的分配上下文(它最初被放置的位置)。
class Assignment(base.Assignment):
...
class Renderer(base.Renderer):
def base_folder(self):
# self.context is the current context.
# but how to access the folder, to which the portlet has been assigned?
...
在 self.manager 和 self.data 中搜索“分配”上下文,但没有找到任何合适的内容。
可能有一些解决方法:比如搜索从 self.context 到带有 portlet 的文件夹的路径,或者在创建 portlet 时将一些信息保存到分配的实例中,但我想知道是否有一些直接的方法?
I would like to make a context portlet for Plone4, which will be then added to certain folders and visible in their respective subfolders. However, no matter where the portlet is shown I would like to access portlet's assignment context (where it was put in the first place) in the Renderer's instance.
class Assignment(base.Assignment):
...
class Renderer(base.Renderer):
def base_folder(self):
# self.context is the current context.
# but how to access the folder, to which the portlet has been assigned?
...
Searched for the "assignment" context in the self.manager and self.data, but has not found anything suitable.
There could be some workarounds: like searching the path from self.context up to the folder with portlet or saving some information into Assignment's instance upon portlet creation, but I wonder if there is some direct way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想出了以下内容,因为我想提供直接到 portlet 设置对话框的链接。我认为函数末尾context的值就是你想要的对象:
Upd。 2014:看起来人们也可以从 portlet 渲染器的
__portlet_metadata__
属性中拼凑出这些信息,该属性具有键key
(赋值位置)、类别
(例如“上下文”)、manager
(例如“plone.rightcolumn”)和名称
。I came up with the following because I wanted to provide a link directly to the portlet's settings dialog. I think the value of context at the end of the function is the object you want:
Upd. 2014: it also looks like one might be able to piece together this information from the portlet renderer's
__portlet_metadata__
property, which has the keyskey
(location of assignment),category
(e.g. 'context'),manager
(e.g. 'plone.rightcolumn') andname
.