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?
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.