plonewars.com

March 4th, 2007

Erik Forsberg: Evaluating Photo Albums for Plone

<ul>
<li><p class=”first”><a class=”reference” href=”http://www.zphotoalbum.org”>ZPhotoSlides</a>: Well, seems rather competent. Documentation hints
about ability to read photos from file system, but how? Very hard to
understand where to find that functionality. That would be very
useful, though.</p>
<p>Adding a ZPhotoSlidesFolder doesn’t seem to work at all, possibly
because of trying to use ZPhotoSlides under Plone 2.1.</p>
<p>Webpage of product seems to be quite outdated. The only &quot;working
demo&quot; of version 2.0 gives a 404. Hmm..</p>
</li>
<li><p class=”first”><a class=”reference” href=”http://plone.org/products/atphotoalbum”>AT Photo Album</a>: Adding an AtPhotoAlbum object gives me a
folder-like object without any possibility to edit anything. I
think product is not Plone 2.1-ready.</p>
</li>
<li><p class=”first”><a class=”reference” href=”http://plone.org/products/atphoto”>ATPhoto</a>: Doesn’t seem to have much functionality. Fails to display
the single photo I added in view mode.</p>
</li>
<li><p class=”first”>CMFPhotoAlbum: 0.5.0 fails to install due to missing
navigation_properties in Plone 2.1. Trunk from SVN installs, but
trying to add a Photo Album gives a 404.</p>
<p>Trying to find the canonical web page for CMFPhotoAlbum seems impossible.</p>
</li>
<li><p class=”first”>The built in photo album view in Plone 2.1 is not good enough for my
demands.</p>
</li>
</ul>
<p>Nah, I’ll stick with the album generated by <a class=”reference” href=”http://kofoto.rosdahl.net”>Kofoto</a> for a
while. <a class=”reference” href=”http://efod.se/photos”>Here’s my photos</a>.</p>

Erik Forsberg: Evaluating Photo Albums for Plone

Originally from Planet Plone by Erik Forsberg


from Yoda http://plonewars.com/2007/03/04/erik-forsberg-evaluating-photo-albums-for-plone/







March 4th, 2007

Erik Forsberg: Plone 2.5.2 and LDAP – revisited

One or two years ago, I spent some time trying to understand how to connect Plone 2.0 to LDAP. I really had no luck as things were complicated. Reading out existing users from the directory might have been possible, but trying to create users was a thing never heard of.

I decided to check out the current state of Plone and LDAP again with amore modern version of Plone, in my case, Plone 2.5.2. After some heavy experimentation, I’ve come to the conclusion that the software involved has grown more mature, but it’s still hard to get it working.

Sources of Information

Software Requirements

  • python-ldap. Make sure the python that is used to run Zope has this module available, or nothing at all will work.
  • LDAPUserFolder. I used version 2.8beta.
  • LDAPMultiPlugins. I first tried version 1.4, but got some problems. Version 1.5, released yesterday(!), works much better.
  • The LDAPMultiPlugins patch available at http://antiloop.plone.org/LDAPMultiPlugins-plone.org.patch. For me, it applied cleanly on top of LDAPMultiPlugins 1.5. It adds functionality that is available and needed by PlonePAS. Group memberships seems to work much better with this patch than without.
  • Two patches, one on CMFPlone/RegistrationTool.py (download here), and one on PasswordResetTool/skins/PasswordReset/registered_notify_template.pt (download here). Without these, registration will fail. Please note that both patches are ugly hacks that are not long-term solutions to the problem.
  • This patch: http://www.zope.org/Collectors/PAS/53/plugin-registry-satisfaction.patch, or login after password reset will fail with a recursion depth error.

Installation

Drop LDAPUserFolder and LDAPMultiPlugins into your Products folder, apply patches listed above, and restart Zope.

Configuration

Follow http://plone.org/documentation/how-to/plone-2-5-and-openldap-integration-for-users-and-groups. In short, you add a LDAP Multi Plugin to your PAS folder (acl_users in ZMI) by using the dropdown in the top right corner and then configure it.

Theory of Operation

Plone 2.5 uses PlonePAS, which is an adaption of Zope’s PAS (the Pluggable Authentication System) for its user/group handling. That is a good thing, as PAS is a very flexible system that can do just about anything.

To get LDAP users/groups/authentication, LDAPMultiPlugins need to be installed and configured. After configuration, LDAPMultiPlugins contain an LDAPUserFolder that is used to actually fetch information from LDAP. The different plugins in LDAPMultiPlugins then add functionality such as authentication, user and group enumeration et. al. to PlonePAS.

Configuration of which LDAP server(s) to use, which base to use etc are made by visiting acl_users -> <your LDAPMultiPlugin> -> Contents -> acl_users. A bit awkward to find, if you ask me.

Notes

It’s very important to pay attention to the LDAP Schema tab under the LDAPUserFolder.

  • The LDAP attribute used to keep the full name of the user must be mapped to fullname. In my case, this means that the LDAP attribute cn should be mapped to fullname. For other directory configurations the attribute may be named differently. Novell eDirectory for example, uses cn as username.
  • The LDAP attributes used to keep the e-mail address of the user must be mapped to email. In most cases this means that the LDAP attribute mail should be mapped to email.
  • Only attributes listed in the LDAP Schema tab are available in the dropdowns used to select which field to use as login name attribute, username etc in the configuration of LDAPUserFolder.
  • All attributes listed as MUST in the LDAP schemas used to create new users (and search for existing) must be listed under the LDAP Schema. If not, user registration will fail due to LDAP schema errors.

It’s also very important to pay attention to the list of User Object Classes  in the configure tab. This list is used both to construct the query used when searching for user objects, and to create new user objects at registration. At new user registration, an LDAP object is first created with all attributes (except the RDN attribute) set to [unset] in the LDAP database. As mentioned above, all attributes listed under the LDAP Schemas tab are filled with this value. Later on in the registration codepath, the attributes actually mapped to plone attributes are set (one attribute at a time, in separate LDAP requests).

The order of the PAS Plugins is very important. To get user registration to work, and for other things as well, the LDAP Multi Plugin should be at top of the list of plugins for each type of plugin.

For (much) better performance, add caching by visiting the Caches tab of both ZMI->acl_users and your LDAP Multi Plugin. Adding a cache to source_groups also seems like a good idea (there’s no cache tab, so you’ll have to find the URL to the cache management yourself – it’s something like http://uterus:8080/Plone/acl_users/source_groups/ZCacheable_manage. For me, it seems to work using the RAM Cache Manager that already exist in any Plone 2.5 installation.

That’s all the things I can remember as being important from yesterday’s late night session :-) .

Erik Forsberg: Plone 2.5.2 and LDAP – revisited

Originally from Planet Plone by Erik Forsberg


from Yoda http://plonewars.com/2007/03/04/erik-forsberg-plone-252-and-ldap-revisited/







March 4th, 2007

Erik Forsberg: Blog-Trouble! Re-post, again!

<p>Gah!</p>
<p>I tried to install <a class=”reference” href=”http://plone.org/products/visitorcomments”>VisitorComments</a> to allow anonymous users to leave
their name when they commented blog entries.</p>
<p>By some, yet to be known, reason, this f*cked up my something in the
blog, so comments are now added to the root of the blog instead of to
the relevant entry. Uninstalling VisitorComments didn’t help :-( .</p>
<p>This seems to be a known problem according to Olivier Ozoux on the
quills mailing list, but his proposed solution – to remove the blog
and then re-post all the entries, doesn’t work for me, now when I
decided to give it a try, even though it’s a rather annoying thing to
do..</p>

Erik Forsberg: Blog-Trouble! Re-post, again!

Originally from Planet Plone by Erik Forsberg


from Yoda http://plonewars.com/2007/03/04/erik-forsberg-blog-trouble-re-post-again/







March 4th, 2007

Erik Forsberg: Fixed the Comment Problem

<p>Finally managed to fix the problem with VisitorComments and Quills, so
now it’s possible to comment on this blog in a decent manner again.</p>
<p>I’ve written about the <a class=”reference” href=”http://lists.etria.com/pipermail/quills-dev/2006-January/000874.html”>solution to the problem</a> on the Quills mailing list.</p>

Erik Forsberg: Fixed the Comment Problem

Originally from Planet Plone by Erik Forsberg


from Yoda http://plonewars.com/2007/03/04/erik-forsberg-fixed-the-comment-problem/







March 4th, 2007

Erik Forsberg: Sometimes, there’s a Product Just For You

<p>Today, the marketing person at work came and told me that he wanted a
signup form for a usergroup meeting we’re planning. Something simple
that mailed him with the relevant information.</p>
<ul class=”simple”>
<li><em>&quot;OK, I’ll go see if I can fix something like that..&quot;</em></li>
</ul>
<p>I had heard about <a class=”reference” href=”http://plone.org/products/ploneformmailer”>PloneFormMailer</a> earlier, so I did some quick
research on it, including asking on #plone to verify that it works in
Plone 2.1, and installed it in my staging instance.</p>
<p>It solved my problem perfectly!</p>
<p>This is one of the things I like about plone – very often, someone
else has already solved the web publishing problem you’re having right
now, and you can use an existing product instead of having to create
your own.</p>
<p><a class=”reference” href=”http://plone.org/products/ploneformmailer”>PloneFormMailer</a> uses <a class=”reference” href=”http://www.zope.org/Members/infrae/Formulator”>Formulator</a>, which also looks very interesting
for some of my needs – for example, I have a custom-written product
that fiddles with some LDAP values, and I could probably use
Formulator or some other similar product. <a class=”reference” href=”http://plone.org/documentation/how-to/integrating-form-controller-with-formulator”>this HOWTO</a> seems
interesting.</p>

Erik Forsberg: Sometimes, there’s a Product Just For You

Originally from Planet Plone by Erik Forsberg


from Yoda http://plonewars.com/2007/03/04/erik-forsberg-sometimes-theres-a-product-just-for-you/







March 4th, 2007

Erik Forsberg: efod.se – now with nice looking titles on WebDAV-uploaded HTML!

<p>Plone 2.1-2.1.2 has an irritating bug – HTML files uploaded via WebDAV
gets the filename as page title, which looks very ugly.</p>
<p>I’ve now created a patch for this that restores the behaviour of Plone
2.0.x, where the title is extracted from the &lt;title&gt; tag.</p>
<p>Check out <a class=”reference” href=”https://dev.plone.org/plone/ticket/4877″>https://dev.plone.org/plone/ticket/4877</a> for the patches. I’m
now eagerly awaiting feedback from the Plone developer responsible for
the bug.</p>

Erik Forsberg: efod.se – now with nice looking titles on WebDAV-uploaded HTML!

Originally from Planet Plone by Erik Forsberg


from Yoda http://plonewars.com/2007/03/04/erik-forsberg-efodse-now-with-nice-looking-titles-on-webdav-uploaded-html/







March 4th, 2007

Erik Forsberg: /etc/init.d/zope2.8 restart on Ubuntu

<p><em>/etc/init.d/zope2.8 restart</em> didn’t work on my Ubuntu Server 5.10. It
turns out that it’s using Ubuntu’s homebrewn <em>dzhandle</em> script to
handle plone instances. You are supposed to create instances using
dzhandle. If you do, there’ll be a file named <em>debian_policy</em> in the
<em>etc</em> directory of the instance, and if that file exists, dzhandle
will recognize the instance and happily restart it.</p>

Erik Forsberg: /etc/init.d/zope2.8 restart on Ubuntu

Originally from Planet Plone by Erik Forsberg


from Yoda http://plonewars.com/2007/03/04/erik-forsberg-etcinitdzope28-restart-on-ubuntu/







March 4th, 2007

Erik Forsberg: The Mystery of the Lost Content Types

<p>I was puzzled yesterday when I uploaded a file via WebDAV. Since the
file was equipped with a Content-Type header, I expected it to be
parsed as reStructured Text. Instead, it appeared as a DTML
document. The horror! The horror!</p>
<p>It turned out that the predicate list in the content_type_registry was
empty. I don’t know why. I recently upgraded the Plone instance from
2.1.0 to 2.1.2, that could be related.</p>
<p>By removing and then reinstalling the ATContentTypes product with the
Add/Remove Products tool, the problem went away.</p>
<p>Odd.</p>

Erik Forsberg: The Mystery of the Lost Content Types

Originally from Planet Plone by Erik Forsberg


from Yoda http://plonewars.com/2007/03/04/erik-forsberg-the-mystery-of-the-lost-content-types/







March 4th, 2007

Erik Forsberg: Plone Development Experiences

<p>For the last days, I’ve been doing some heavy Plone development for a
community site that hopefully will be launched sometime during the
next few days. Although I have done a fair amount of Plone development
earlier, this time, I did learn a lot, especially about ArchGenXML.</p>
<div class=”section” id=”content-types”>
<h3><a name=”content-types”>Content Types</a></h3>
<p>When I first started using Plone, I had trouble understanding the
concept of &quot;content types&quot;. All the documentation was talking about
content types. Everybody was speaking about them, but I didn’t want
content types, I just wanted some scripts to create some users in an
LDAP database. I ended up tacking ZPT files to existing content
types. Ugly and very hackish.</p>
<p>Now, I think I’ve understood the concept. In Plone, all content is an
instance of a content type. You need a page creating users in an LDAP
database? It’s a CreateUsersPage Content Type! That’s how to do it
with Plone. At least that’s my current understanding.</p>
<p>For this project however, the idea of content types was very easy to
apply to the problem. The community wants to build a database of
applications that work in a specific environment (I’m a bit secretive
on this project since it’s not set in production yet) – that’s a
perfect match. Each application in the database is modelled as an
AppDBApplication content type. There’s AppDBCategory objects, and last
but not least, the AppDB content type which holds AppDBCategory and
AppDBApplication objects.</p>
</div>
<div class=”section” id=”working-with-archgenxml”>
<h3><a name=”working-with-archgenxml”>Working with ArchGenXML</a></h3>
<p><a class=”reference” href=”http://plone.org/products/archgenxml”>ArchGenXML</a> is a code generator for Plone, or more specifically for
Archetypes-based content types. Archetypes is the framework for
creating content types that is used in Plone, at least in recent
versions.</p>
<p>Basically, you create an UML diagram using some UML editor such as
<a class=”reference” href=”http://argouml.tigris.org”>ArgoUML</a>. <a class=”reference” href=”http://plone.org/products/archgenxml”>ArchGenXML</a> then generates code based on the information in
the UML diagram. This sounds complicated, and it has a somewhat steep
learning curve, but once you get it, it’s a very productive way to
create Plone <em>Products</em> – A <em>Product</em> is another Plone concept. It’s
something you install in your Plone instance which keeps a bunch of
related code together, for example some content types and their ZPT
templates and some tools used by the content types together with for
example custom workflows.</p>
<p><a class=”reference” href=”http://plone.org/products/archgenxml”>ArchGenXML</a> generates all the boilerplate needed to create a product,
including code to interact with the product installer inside
Plone. Very handy.</p>
<p>If you haven’t done so already, you really need to read the
<a class=”reference” href=”http://plone.org/documentation/tutorial/archgenxml-getting-started”>ArchGenXML tutorial</a></p>
<p>In this project, I created a class in the UML diagram for each type of
content so there was one AppDB class, one AppDBApplication class and
one AppDBCategory class. The AppDBApplication and AppDBCategory
classes were then <em>Associated</em> (an UML term) with AppDB, which
automatically makes AppDB a folder class that can hold objects of
AppDBCategory and AppDBApplication.</p>
<p>Each class is then equipped with attributes and operations. The
attributes end up as automatically generated input forms and
automatically generated renderings of the data in the end. This is
very handy! In my AppDBApplication for example, I added an attribute
called ‘version’ for storing the version of the piece of software that
each object in the database refers to. After generating the code with
ArchGenXML, I end up with an Archetypes class that automatically
creates an input form where for the version attribute, as well as an
automatically generated page for viewing all the data, where the
version field is included.</p>
</div>
<div class=”section” id=”customizing-view-and-edit-templates”>
<h3><a name=”customizing-view-and-edit-templates”>Customizing View and Edit Templates</a></h3>
<p>Another thing I understood just recently was how you are supposed to
edit the view and edit pages for Archetypes-based content types in a
decent way. The HOWTO named <a class=”reference” href=”http://plone.org/documentation/how-to/how-to-customise-view-or-edit-on-archetypes-content-items/view?searchterm=base_view”>How to Customize View or Edit on Archetypes Content Items</a> is really a <em>must read</em>!</p>
<p>Using the templates in the HOWTO as a basis for your view and edit
forms makes Archetypes development much easier since it takes care of
some of the fuzz, such as making sure there are relevant variables
already defined in your template.</p>
<p>Make sure you read the whole HOWTO, including its comments. There is
one real goodie in one of the comments – the basis for how to create
edit forms that don’t look like all other edit forms in
Archetypes. Here’s how you do it:</p>
<ol class=”arabic”>
<li><p class=”first”>Create a new filesystem template named
&lt;nameofyourcontenttype&gt;_edit.pt. Place it in the skins folder of
your product. Use the edit template in the HOWTO as base, or use
this stripped-down version:</p>
<blockquote>
<pre class=”literal-block”>
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;
xml:lang=&quot;en&quot;
lang=&quot;en&quot;
xmlns:tal=&quot;http://xml.zope.org/namespaces/tal&quot;
xmlns:metal=&quot;http://xml.zope.org/namespaces/metal&quot;
xmlns:i18n=&quot;http://xml.zope.org/namespaces/i18n&quot;
i18n:domain=&quot;plone&quot;&gt;
&lt;metal:head define-macro=&quot;topslot&quot;&gt;
&lt;/metal:head&gt;

&lt;metal:head define-macro=&quot;javascript_head&quot;&gt;
&lt;/metal:head&gt;
&lt;body&gt;
&lt;!– body, editform , fields, buttons, the default macro
contains a number of slots which usually provide enough
ways to customise so often I use that macro and just
fill the slots
–&gt;
&lt;metal:body define-macro=&quot;body&quot;&gt;
&lt;metal:default_body use-macro=&quot;here/edit_macros/macros/body&quot;&gt;

&lt;metal:block fill-slot=&quot;widgets&quot;&gt;
&lt;!– This is where you’ll add widgets –&gt;
&lt;/metal:block&gt;
&lt;/metal:default_body&gt;
&lt;/metal:body&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
</blockquote>
</li>
<li><p class=”first”>Inside the <em>&lt;metal:block fill-slot=&quot;widgets&quot;&gt;</em> tags, add one of
these for each field in your schema that you want to appear in the
edit forms:</p>
</li>
</ol>
<pre class=”literal-block”>
&lt;metal:fieldMacro use-macro=&quot;python:here.widget(&lt;name of your field&gt;, mode=’edit’)
</pre>
<p>Of course, replace <em>&lt;name of your field&gt;</em> with the name of the fields
for which you want the input field to appear, as defined in the schema
of your archetype class. You are free to use any html elements and css
to position the widgets where you want them.</p>
</div>
<div class=”section” id=”customizing-widgets”>
<h3><a name=”customizing-widgets”>Customizing Widgets</a></h3>
<p>In this project, I wanted some javascript to be triggered when one of
the input fields is modified. It’s a simple thing – I want some other
input fields to enabled or disabled based on the value of the first
input field (a radio button collection with two alternatives).</p>
<p>I had no idea on how to accomplish this, so I asked on the #archetypes
IRC channel on freenode. The trick is to copy the ZPT template used to
display the widget you are using to your own skins directory, naming
it appropriately, then using the macro attribute on the widget in the
archetypes schema, point to the new template. An example:</p>
<dl class=”docutils”>
<dt><em>) I have a field named *operatingsystem</em> in my archetypes</dt>
<dd><p class=”first”>schema. It’s defined as follows:</p>
<pre class=”literal-block”>
StringField(
name=’operatingsystem’,
widget=SelectionWidget(
label=&quot;Written for&quot;,
description=&quot;The operating system the application originally was written for&quot;,
macro=&quot;appdb_widgets/appdbapplication_selection&quot;,
label_msgid=’AppDB_label_operatingsystem’,
description_msgid=’AppDB_help_operatingsystem’,
i18n_domain=’AppDB’,
),
vocabulary=NamedVocabulary(&quot;&quot;&quot;operatingsystem&quot;&quot;&quot;)
),
</pre>
<p>I’m using <a class=”reference” href=”http://plone.org/products/atvocabularymanager”>ATVocabularyManager</a> in this project, hence the
<em>NamedVocabulary</em> as vocabulary.</p>
<p class=”last”>Note the line <em>macro=appdb_widgets/appdbapplication_selection</em>.</p>
</dd>
<dt><em>) Since the field is using a *SelectionWidget</em>, I copied</dt>
<dd><p class=”first”><em>selection.pt</em> from <em>&lt;instance
home&gt;/Products/Archetypes/skins/archetypes/widgets</em> into the
directory <em>appdb_widgets</em> in the skins dir for my product and named
the copied file <em>appdbapplication_selection.pt</em>.</p>
<p class=”last”>Note: <em>Do not</em> call the subdirectory in your skins dir <em>widgets</em>,
since that will most likely give you an error because Plone will
then try to find template files for other widgets in your skins
directory, where they will not be available. This has to do with
the search order in the plone skins tool.</p>
</dd>
<dt><em>) Now edit *appdb_widgets/appdbapplication_selection.pt</em> and add the</dt>
<dd>call to a javascript function.</dd>
</dl>
</div>

Erik Forsberg: Plone Development Experiences

Originally from Planet Plone by Erik Forsberg


from Yoda http://plonewars.com/2007/03/04/erik-forsberg-plone-development-experiences/







March 4th, 2007

Erik Forsberg: Updated site to Plone 2.5.1

I finally have upgraded this site to Plone 2.5.1. There’s no big changes for the casual viewer. About the only visual changes are in the blog, which I’ve upgraded from Quills 0.9 to Quills trunk. In the non-visual department, the syndication feeds now contain category names, which will make technorati happier. Speaking of technorati – I wonder why it doesn’t pick up changes to this blog.

The blog software upgrade was not completely painless, so to speak. All entries in the blog were flagged by new in the syndication feeds, not to mention that they were displayed as html code. That problem went away when upgrading the basesyndication product as well.

I honestly don’t know if this problem is present in Quills 1.5RC3, as I had some other strange error there. I do however think this was more related to a locally modified template.

Oh well.

Erik Forsberg: Updated site to Plone 2.5.1

Originally from Planet Plone by Erik Forsberg


from Yoda http://plonewars.com/2007/03/04/erik-forsberg-updated-site-to-plone-251/