[Product-Developers] Re: portlet rendering in python code

Daniel Widerin daniel at widerin.net
Fri May 2 23:02:12 UTC 2008

Martin Aspeli schrieb:
> Daniel Widerin wrote:
>> Hello,
>> I need some portlets to be rendered (i need their rendered html code) 
>> in browser view. these portlets expect only one parameter, an 
>> object_uid, which i passed to portlet renderer successfully.
> Why? :)
> It sounds to me like you should just do this with views or 
> ViewPageTemplateFiles or viewlets.

i want to select portlets in kupu using mediaobjects to make "content 
portlets" being rendered in kupu-text.

i added some of my custom types (which all have a portlet too) to 
mediaobject resource types in kupu configuration to make them selectable 
using the place-image-button.

i added these types into the action-url table in kupu configuration
normal image:

now i can add my types using placeholder images into my kupu text, and 
give them image-left, image-right classes to make text float around.

on save i replace ${object_url} with physicalpath of the selected 
object. (sorry, but only portal_type and object_url are available in 
kupu resource types configuration).

in my browser view, i parse the kupu-text and replace all images with 
img-tags which use the 
contentPlugin_${portal_type}.gif?ContentPluginUrl=${object_url} scheme 
with the rendered portlet code. through the physicalpath i can locate 
the object and then get the rendered portlet using an adapter with my 
own factory.

i hope you understand what i'm trying to do here, i know it's not a nice 
way but using the kupu place-image-button makes it very simple for 
reviewers to add such content portlets

>> i tried to call the portlet directly and construct the parameters for 
>> the render method, but still failed.
> You need to be more specific about what you tried.
> The general approach should be to get the portlet assignment, make sure 
> it's acquisition-wrapped, and then adapt to IPortletRenderer, making 
> sure the portlet renderer is acquisition wrapped in the context, and 
> then call update() and then render() on it.
> You'll need to look at the portlet manager code, in particular 
> _lazyLoadPortlets().
>> i get a Unauthorized Exception in DC.Bindings as described here: 
>> http://plone.org/documentation/error/unauthorized-not-authorized-to-access-binding-context 

i still get the unauthorized exception - but it works if i do a
except Unauthorized:

instead of raising the UnauthorizedBindingException. I think i have to 
search the right context for doing such things...

>> how do i construct a portlet-manager in python (tried some stuff from 
>> plone.portlets.manager already), do i need one?
> Probably not, strictly speaking, but portlets weren't really designed to 
> be easily rendered in isolation. It's certainly possible - you could 
> look at some of tests in plone.app.portlets for inspiration - it's just 
> not a use case that's considered particularly important.
> Martin

thanks for help, it took me some steps ahead...


More information about the Product-Developers mailing list