Plone4 Monkeypatching TinyMCE

Plone 4.3.3 (4308), CMF 2.2.7, Zope 2.13.22, Python 2.7 (r27:82500, Aug 07 2010, 16:54:59) [GCC], TinyMCE 1.3.6 (I know, environment is out of date but upgrading at this point in time is not possible for me with the amount of sites I have to maintain for the state and my current queue)

Hi all, I have been struggling with trying to allow TinyMCE to accept custom tags in our environment. I found a guide for how to accomplish this from the plone docs, http://glicksoftware.com/blog/disable-html-filtering, but the monkey patching part has been difficult for me. I found another article on how to use collective.monkeypatcher, https://encolpe.wordpress.com/2009/07/13/manage-monkey-patches-and-performance-improvement-in-plone-3/, but it is a little out of date and does not seem to be working, but I could be doing something wrong.

For starters, I could not get the monkeypatcher control panel to show up in my zope or plone control panel even though buildout and debug claim the addon has been installed. I modified configure.zcml in our custom policy product, added a patches.py and patches.zcml. This is what they look like:

patches.py
getValidElements = lambda self: {'*': ['*']}

patches.zcml

            <include package="collective.monkeypatcher" />

            <monkey:patch
                description="This is to make TinyMCE allow custom tags"
                class="Products.TinyMCE.utility.TinyMCE"
                original="getValidElements"
                replacement=".patches.getValidElements"
                />

    </configure>

added to configure.zcml:
<include file="patches.zcml" />

location of custom policy product: Plone433/zeocluster/src/united.policy/united/policy/configure.zcml

Is there something I am not understanding about the monkeypatching process? Should there be somewhere else I "inject" this patch?

Thank you so much for taking the time to read this.

Hello Keith,

That's weird, I'm using the exact same monkey:patch for adding allowfullscreen attributes to iframes. The two things I did different:

  • I added the monkey:patch directive directly to the main configure.zcml in my add'on (policy package for a site) (no ). Can you try moving it to the main configure.zcml?
  • I copied the getValidElements verbatrim from Products.TinyMCE and added my attibutes. but looking in the code your solution is what happens when html transform is disabled and should work as well.

Where did you find a reference to collective.monkeypatcher having a control panel? Not all Plone add'ons necessarily add a control panel (only if they need to expose settings to the webmaster), AFAIK collective.monkeypatcher has no control panel and only logs succesful patches to the log upon startup.

Hi Fred,

The controlpanel was a separate addon, https://pypi.python.org/pypi/collective.monkeypatcherpanel/1.0.4

Do you mean you modified the configure.zcml inside the tinyMCE product itself? I don't know of any other configure.zcml. This is what my site structure looks like:

/usr/local/Plone433
/Plone433 buildout.cache zeocluster
/Plone433/zeocluster/ bin develop-eggs buildout.cfg parts products src var
/Plone433/zeocluster/products is empty, all site addons are stored in buildout.cache
/Plone433/zeocluster/src/ contains all our custom products, united.policy and united.theme

united.policy is the main policy product for the site, thats why I thought its configure.zcml would had been the one. But what I think is happening is tinymce is loading after united.policy and so the monkeypatch is being overwritten?

I did a find -name configure.zcml on Plone433, I see a bajillion configure.zcmls inside buildout.cache/eggs, but those are for each of the core products and plone. I assume I want to avoid modifying code there. The only other configure.zcmls in the codebase are in united.theme and united.policy.

Thanks

FYI, I added allowfullscreen attribute in https://github.com/plone/Products.TinyMCE/commit/66989447b6b50873d1bc2de5c2cfef7602bc16a0 (it's in Products.TinyMCE 1.3.25)