Re: [Plone-Users] plone scripting
Ralf Hemmecke <[email protected]> Sun, 08 May 2011 22:10:30 +0200
| Newsgroups | gmane.comp.web.zope.plone.documentation,gmane.comp.web.zope.plone.user |
|---|---|
| Message-ID | <[email protected]> |
On 05/08/2011 08:02 PM, ajung wrote:
> You got a solution for the Extensions question. Why don't you follow this
> road?
Because, I also want to learn how to control plone from the unix command
line.
> Apart from that: I think you need
>
> zope.app.component.hooks.setSite(portal)
>
> inside your script if you want to run it through
>
> bin/instance run yourscript.py
Thanks for this tip. I had to additionally import zope but otherwise it
worked. Thank you!
To somebody who maintains
http://plone.org/products/tinymce/documentation/how-to/how-to-set-tinymce-as-default-editor-for-current-users
and
http://collective-docs.plone.org/misc/commandline.html
could you perhaps update appropriately?
It's probably easier to run a script via
bin/client2 run kupu2tinymce.py
than creating an external method.
And for the commandline... as Andreas pointed out,
import zope
zope.app.component.hooks.setSite(portal)
was missing.
Ralf
PS:
My script for setting TinyMCE is
=== kupu2tinymce.py ===
def Kupu2TinyMCE(self):
pm = self.portal_membership
for memberId in pm.listMemberIds():
member = pm.getMemberById(memberId)
editor = member.getProperty('wysiwyg_editor', None)
if editor == 'TinyMCE':
print('%s: TinyMCE already selected, leaving alone' % memberId)
else:
member.setMemberProperties({'wysiwyg_editor': 'TinyMCE'})
print('%s: TinyMCE has been set' % memberId)
return
portal = app.YOURPLONESITE
import zope
zope.app.component.hooks.setSite(portal)
Kupu2TinyMCE(portal)
import transaction
transaction.commit()
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today. Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd