Note that there are some explanatory texts on larger screens.

plurals
  1. POExecuting Content Rules Programmatically using a PloneFormGen Custom Script Adapter
    primarykey
    data
    text
    <h2>Some basic info</h2> <p>I have a Plone 3.2.1 site, which has a sub folder named <strong>prod</strong>. There is also a PloneFormGen form named <strong>upload</strong>, which has a custom script adapter that creates a custom content type (slight modification of the 'Collection' type) and places it in the aforementioned <strong>prod</strong> folder. </p> <p>The <strong>prod</strong> folder has a content rule configured, which has the following conditions:</p> <ul> <li>Type == "My Custom Type"</li> <li>State == "Private"</li> </ul> <p>If those conditions are met, it will send me an email saying there is a new content type awaiting my review. </p> <h2>The issue</h2> <p>When using a custom script adapter to create content types, it seems the content rules are bypassed or ignored. Of course manually creating a "My Custom Type" via the "Add new..." menu executes the rule as expected.</p> <h2>My thoughts</h2> <p>As far as I can see I only have 3 options</p> <ol> <li>install <a href="https://pypi.python.org/pypi/uwosh.pfg.d2c" rel="nofollow">uwosh.pfg.d2c</a> <ul> <li>This would be ideal but seems to break my installation (client1 refuses to load after this is added to buildout, it complains about a permission issue, it also seems to cause the same issue on a vanilla Plone 4.3 install)</li> </ul></li> <li>Write something in my script that can talk to Plone's mailhost and send a custom email </li> <li><strong>Find a way to execute a content rule in my script</strong></li> </ol> <p>Number 3 on this list is where I want to go, although I can't find much information on it, leading me to think it might be quite complicated.</p> <h2>Question summary</h2> <p>Is it possible to execute an already existing content rule using a PloneFormGen custom script adapter? If it is possible, does anyone have documentation or an example of it?</p> <h2>Script Adapter script if you need to see it:</h2> <pre><code>from DateTime import DateTime target = context.prod form = request.form uid = str(DateTime().millis()) target.invokeFactory("My Custom Type", id=uid, title=form['title-1']) obj = target[uid] obj.setFormat('text/plain') obj.setTitle(form['title-1']) obj.setDescription(form['description-1']) obj.setText(form['main-information']) obj.setCustcode(form['customer-code']) obj.setProdcode(form['product-code']) obj.setMsector(form['market-sector']) obj.setProdcat(form['product-category']) obj.setOrderdate(form['order-date']) obj.setSalesrep("rep: " + form['sales-rep']) obj.setKeywords(form['keywords-1']) obj.setSubject(form['product-code']) criteria = obj.addCriterion('Type', 'ATPortalTypeCriterion') criteria.setValue("Image") criteria = obj.addCriterion('Subject','ATSimpleStringCriterion') criteria.setValue(form['product-code']) obj.reindexObject() </code></pre> <p>I am still working on this so the question may be modified as I progress through this issue. Although any help or insight would be greatly appreciated.</p> <h2>Edit #1</h2> <p>I was on the Plone chat room and someone suggested I look into <a href="http://nullege.com/codes/search/zope.lifecycleevent.ObjectAddedEvent" rel="nofollow">ObjectAddedEvent</a>. This is probably what I am looking for although I am unable to import those modules via a custom script adapter and would like to avoid having to write a script that resides on the file system.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload