https://www.rpatterson.net/Ross Patterson's Blog - Posted in 20092023-08-22T15:29:27.200590+00:00ABloghttps://www.rpatterson.net/blog/testbrowser-patches/testbrowser Patches2009-08-23T00:00:00+00:00Ross Patterson<section id="testbrowser-patches">
<blockquote>
<div><p>collective.testcaselayer 1.2 includes some patches for functional browser testing</p>
</div></blockquote>
<p>To use these patches, include the collective.testcaselayer
configure.zcml. The patches address some bugs in
Testing.ZopeTestCase.</p>
<section id="data-streamed-to-the-response">
<h2>Data streamed to the response</h2>
<p>Due to some behavior in Testing.ZopeTestCase.zopedoctest.functional,
the testbrowser.contents was empty when data had been streamed
directly into the response (as opposed to returning the data from the
callable published). This made it difficult to do functional testing
for code that needed to stream data to the response for performance,
such as when the response data is very large and would consume too
much memory.</p>
</section>
<section id="http-referrer">
<h2>HTTP_REFERRER</h2>
<p>Due to <a class="reference external" href="https://bugs.launchpad.net/bugs/98437">bug #98437</a>,
“TestBrowser Referer: header set to ‘localhost’”, some testbrowser
requests would raise NotFound. Two examples would be visiting the
Plone login_form directly rather than following a link, or using the
Plone content_status_history form.</p>
<div class="note update admonition">
<p class="admonition-title">Updated on 23 August 2009</p>
<p>Imported from Plone on Mar 15, 2021. The date for this update is the last
modified date in Plone.</p>
</div>
</section>
</section>
collective.testcaselayer 1.2 includes some patches for functional browser testing2009-08-23T00:00:00+00:00https://www.rpatterson.net/blog/collective.gsqi/collective.gsqi2009-08-23T00:00:00+00:00Ross Patterson<section id="collective-gsqi">
<blockquote>
<div><p>A grab bag of patches to GS and portal_quickinstaller</p>
</div></blockquote>
<p>This <a class="reference external" href="http://pypi.python.org/pypi/collective.gsqi">package</a> is my grab bag of patches to GS and portal_quickinstaller
I use in my client work. It is unstable, unpolished, subject to my
whim, and really should be experimental.gsqi. If, however, the same
GenericSetup and portal_quickinstaller quirks and bugs bother you, or
the same conveniences are of value to you, you might want to look at
whats in it.</p>
<blockquote>
<div><ul class="simple">
<li><p>Fix <a class="reference external" href="http://dev.plone.org/collective/browser/collective.gsqi/trunk/collective/gsqi/workflow/exportimport.py">import of group roles</a>
during workflow import</p></li>
<li><p>Fix <a class="reference external" href="http://dev.plone.org/plone/ticket/8350">circular import handler dependencies</a> bug</p></li>
<li><p>Fix portal_quickinstaller so that <a class="reference external" href="http://dev.plone.org/collective/browser/collective.gsqi/trunk/collective/gsqi/qi.py">persistent data is not lost</a>
on reinstall</p></li>
</ul>
</div></blockquote>
<p>Also included are a number of perhaps naughty extensions to the CMF
content import handler.</p>
<blockquote>
<div><ul class="simple">
<li><p>Permissive registrations of the StructureFolderWalkingAdapter so
that folders under the profile’s “structure” folder with the same
name as in the container’s .objects file can be used to import any
kind of content object, not just folders. This allows, amongst
other things, creating topics/collections and criteria on import.</p></li>
<li><p>Set arbitrary AT fields on import using the options under the
[FIELDS] section of .properties as field names and the option
values as field values. If field.multiValued is True, then the
option value will be split on newlines and each value stripped.</p></li>
<li><p>Reindex imported objects so that imported titles, descriptions,
and any other AT fields are reflected in the catalog and portal
navigation after import.</p></li>
<li><p>Set local roles on import where each option under the [ROLES]
section of .properties is the principal/user id and the roles
assigned to that principal are taken from the option value split
at newlines with each item stripped.</p></li>
<li><p>Do each workflow transition listed under the “transitions” option
of the [DEFAULT] section of .properties. The option value is
split at newlines with each item stripped.</p></li>
<li><p>Set display layout using the layout option in the [DEFAULT]
section of .properties</p></li>
</ul>
</div></blockquote>
<p>Also included is <a class="reference external" href="../gsml">GSML</a> which
allows implementing GS import handlers as you would implement ZCML
directive handlers. Some import handlers are included in
collective.gsqi that make use of GSML.</p>
<blockquote>
<div><ul class="simple">
<li><p>A <a class="reference external" href="http://dev.plone.org/collective/browser/collective.gsqi/trunk/collective/gsqi/group/README.txt">groups import handler</a></p></li>
<li><p>A <a class="reference external" href="http://dev.plone.org/collective/browser/collective.gsqi/trunk/collective/gsqi/refs/meta.py">references import handler</a></p></li>
</ul>
</div></blockquote>
<div class="note update admonition">
<p class="admonition-title">Updated on 23 August 2009</p>
<p>Imported from Plone on Mar 15, 2021. The date for this update is the last
modified date in Plone.</p>
</div>
</section>
A grab bag of patches to GS and portal_quickinstaller2009-08-23T00:00:00+00:00https://www.rpatterson.net/blog/collective.formcriteria-folder_contents/collective.formcriteria folder_contents2009-08-23T00:00:00+00:00Ross Patterson<section id="collective-formcriteria-folder-contents">
<blockquote>
<div><p>Managing content with collections</p>
</div></blockquote>
<p><a class="reference external" href="http://pypi.python.org/pypi/collective.formcriteria#id1">collective.formcriteria</a> is quite stable now and the latest release includes some additional features.</p>
<p>Firstly, an “Export” document action (ala “Print”, “Send to”, etc.) allows the collection’s results to be exported to CSV where the columns are those specified in the collection’s “Table Columns” fields. This merges (and deprecates) my collective.catalogexport package and duplicates SmartCSVExporter. One advantage of the collective.formcriteria version is that it will stream the results to the response. Since catalog results are lazy, this should be fairly efficient.</p>
<p>I’ve also tightened up the styling on the search form portlet so it’s not quite as unwieldy. I’d still love to get some contributions here from someone better at CSS than I.</p>
<p>But the most significant piece of work has been to get the folder_contents form to work with collection results. The “Tabular Form” display layout is now available for collections.</p>
<blockquote>
<div><ul class="simple">
<li><p>Use “Table Columns” fields for the folder contents form to control the folder contents columns</p></li>
<li><p>Use a “Table Column Links” collection filed to specify which folder contents form columns should link to the item</p></li>
<li><p>The “Copy”, “Cut”, “Rename”, “Change State”, and “Delete” folder contents form button now all work for objects listed by the collections even if they are in different folders</p></li>
</ul>
</div></blockquote>
<p>With all this in place, collections and formcriteria make a fairly powerful combination for managing Plone content. You can setup a collection with a search form portlet and use search queries to find all the objects you want to apply a workflow transition to, delete, or copy.</p>
<div class="note update admonition">
<p class="admonition-title">Updated on 23 August 2009</p>
<p>Imported from Plone on Mar 15, 2021. The date for this update is the last
modified date in Plone.</p>
</div>
</section>
Managing content with collections2009-08-23T00:00:00+00:00https://www.rpatterson.net/blog/collective.contemplate/collective.contemplate2009-08-23T00:00:00+00:00Ross Patterson<section id="collective-contemplate">
<blockquote>
<div><p>Add content from existing content templates</p>
</div></blockquote>
<aside class="system-message">
<p class="system-message-title">System Message: INFO/1 (<span class="docutils literal">/builds/rpatterson/ross-pattersons-site/blog/collective.contemplate/index.rst</span>, line 15); <em><a href="#id1">backlink</a></em></p>
<p>Duplicate implicit target name: “collective.contemplate”.</p>
</aside>
<p>The <a class="reference external" href="http://pypi.python.org/pypi/collective.contemplate">collective.contemplate</a> package allows
site administrators to designate content items as the template from
which new items of that type will be created.</p>
<p>When creating content from a template, the initial edit form is
rendered and validation performed on the template after changing the
owner of the template to the current user within a
transaction.savepoint() which is rolled back after rendering. As a
result, portal_factory is not involved and indexing occurs only on the
final copy of the template. This may result in performance gains
though this has not been tested.</p>
<p>While designed to be Archetypes agnostic, only an Archetypes
implementation is currently provided. Templates may currently be
designated using Archetype UIDs for the global templates or references
for the context specific templates.</p>
<p>A reserved_id property can also be set on type information objects in
portal_types. If set and an object with that ID already exists in the
container, then the type is not allowed to be added.</p>
<nav class="contents" id="table-of-contents">
<p class="topic-title">Table of Contents</p>
<ul class="simple">
<li><p><a class="reference internal" href="#collective-contemplate" id="id2">collective.contemplate</a></p>
<ul>
<li><p><a class="reference internal" href="#installation" id="id3">Installation</a></p></li>
<li><p><a class="reference internal" href="#usage" id="id4">Usage</a></p></li>
</ul>
</li>
</ul>
</nav>
<section id="installation">
<h2><a class="toc-backref" href="#id3" role="doc-backlink">Installation</a></h2>
<p>To use collective.contemplate for the Plone content types, include the
collective.contemplate configure.zcml in your instance and install
“Content Templates” in the “Add-on Products” control panel, or in the
ZMI through portal_setup. This will replace the Plone content type
information with template versions.</p>
<p>To install for other content types, register a template add form for
the content type and use the TemplateDynamicViewTypeInfo meta_type for
the content type information.</p>
<p>In the ZCML for the browser views:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o"><</span><span class="n">contemplate</span><span class="p">:</span><span class="n">formControllerPage</span>
<span class="n">name</span><span class="o">=</span><span class="s2">"addFoo"</span>
<span class="n">type_name</span><span class="o">=</span><span class="s2">"Foo"</span>
<span class="k">for</span><span class="o">=</span><span class="s2">"zope.app.container.interfaces.IAdding"</span>
<span class="n">permission</span><span class="o">=</span><span class="s2">"foo.AddFoo"</span> <span class="o">/></span>
</pre></div>
</div>
<p>Note that the “foo.AddFoo” permission must be registered and the name
“addFoo” must be the same as your content type constructor. If you’re
using Archetypes, then the constructor may auto-generated by prefixing
“add” to the content class name.</p>
<p>In the GenericSetup profile types.xml file:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o"><</span><span class="nb">object</span> <span class="n">name</span><span class="o">=</span><span class="s2">"Foo"</span> <span class="n">meta_type</span><span class="o">=</span><span class="s2">"TemplateDynamicViewTypeInfo "</span><span class="o">/></span>
</pre></div>
</div>
<p>In the GenericSetup profile types/Foo.xml file:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><?xml version="1.0"?>
<object name="Foo"
meta_type="TemplateDynamicViewTypeInfo">
</pre></div>
</div>
</section>
<section id="usage">
<h2><a class="toc-backref" href="#id4" role="doc-backlink">Usage</a></h2>
<p>This package is currently incomplete until a UI for designating
templates is included. In the mean time, you may set the global
templates in the ZMI or context specific templates using the
references GenericSetup import handler provided by collective.gsqi.</p>
<p>You can use a given content item as the global template by setting the
global_uid property of the content type information under portal_types
in the ZMI. Set global_uid to the Archetypes UID of the template.</p>
<p>You can use a content item as the template in the context of a
specific folder by setting a reference from the folder to the item
with the relationship of “contemplate.${type_info/getId}” where
“${type_info/getId}” is the id of the content type.</p>
<p>A reserved id can be set using the reserved_id property of the content
type information under portal_types in the ZMI.</p>
<div class="note update admonition">
<p class="admonition-title">Updated on 23 August 2009</p>
<p>Imported from Plone on Mar 15, 2021. The date for this update is the last
modified date in Plone.</p>
</div>
</section>
</section>
Add content from existing content templates2009-08-23T00:00:00+00:00https://www.rpatterson.net/blog/gsml/GSML2009-08-23T00:00:00+00:00Ross Patterson<section id="gsml">
<blockquote>
<div><p>GenericSetup import hadlers ala ZCML directive handlers</p>
</div></blockquote>
<p>I’ve gotten so far behind on my blogging, I think it’s time to admit
that I’m not behind, I’ve simply stopped. :) In the hopes that I
start up again, I’d like to write a bit about something I wrote a
while ago and still use today: GSML.</p>
<p>The amount of code duplication involved in writing a properly
declaritive GenericSetup import/export handler has always bothered
me. It seems like most of the duplication involves fairly manually
walking the XML DOM to extract the data needed. I find this to be
very tedious and error prone. I think implementing GS import/export
handlers should have <em>nothing</em> to do with XML.</p>
<p>ZCML does a great job of allowing directive handlers to be simple
Python functions that know nothing of XML. I wrote GSML to bring that
separation of concerns to GS import handlers so I could stop writing
DOM walkers.</p>
<p>Currently, GSML lives in <a class="reference external" href="http://pypi.python.org/pypi/collective.gsqi">collective.gsqi</a> which is just my
grab bag of patches to GS and portal_quickinstaller I use in my client
work. Here’s a doctest that covers <a class="reference external" href="http://dev.plone.org/collective/browser/collective.gsqi/trunk/collective/gsqi/gsml/README.txt">writing an import handler</a>
with GSML. Here’s are a <a class="reference external" href="http://dev.plone.org/collective/browser/collective.gsqi/trunk/collective/gsqi/group/README.txt">groups import handler</a>
and a <a class="reference external" href="http://dev.plone.org/collective/browser/collective.gsqi/trunk/collective/gsqi/refs/meta.py">references import handler</a>
implemented with GSML.</p>
<p>The current implementation of GSML just wraps the ZCML configuration
engine sufficiently to use it for GS import handlers. Since ZCML has
never concerned itself with writing ZCML, however, GSML currently
includes no support for export handlers. This is obviously the most
important TODO.</p>
<p>So please try it out, take a look at it and let me know what you
think. In particular, if anyone out there has any interest in the
export stuff, either in contributing to it, sprinting on it, advising
on it, or anything else, I’d really like to hear from you.</p>
<div class="note update admonition">
<p class="admonition-title">Updated on 23 August 2009</p>
<p>Imported from Plone on Mar 15, 2021. The date for this update is the last
modified date in Plone.</p>
</div>
</section>
GenericSetup import hadlers ala ZCML directive handlers2009-08-23T00:00:00+00:00