def add_portlet(tag, request, site, ref_cat, view):
    klass = tag.attrib.get('class', '').\
                replace(PORTLET_CLASS_IDENTIFIER, '').\
                replace('mce-only ', '').\
                replace('mceNonEditable', '').strip()
    tag.attrib['class'] = tag.attrib.get('class', '').replace('mce-only ', '')
    try:
        html = renderPortletFromHash(klass, request, site=site,
            ref_cat=ref_cat, view=view)
    except:
        html = None
    if html is None:
        tag.getparent().remove(tag)
        return

    style = tag.attrib.get('style', '')
    if style:
        style = style.strip().strip(';') + ';'
    if 'width' in tag.attrib:
        style += 'width:%spx;' % tag.attrib['width'].strip('px')
    if 'height' in tag.attrib:
        style += 'height:%spx;' % tag.attrib['height'].strip('px')
    html = '<div class="tinymceportlet" style="%s">%s</div>' % (
        style, html
    )
    tag.addnext(fromstring(html))
    tag.getparent().remove(tag)
 def __call__(self):
     return renderPortletFromHash(self.request['hash'], self.request)