[Zope-CMF] List of null strings in Subject

Loren Stafford lstafford@morphics.com
Tue, 9 Oct 2001 10:17:10 -0700


I didn't actually fix this in CMF, because I decided to totally control the
Subject vocabulary, thereby eliminating the textarea.

What I did in another custom ZClass/DTML application was create an external
method that filters textarea lists -- something like this:

  from string import strip
  def clean_list(self, list):
    return filter(strip, list)

The DTML form handler cleans the textarea list before storing it in ZODB.
This worked in that old application of mine; I'm not sure we're looking at
exactly the same problem in the case of CMF Subject textareas, but it's
something similar. This case may be different, because the forms
(.../portal_skins/content/metadata_edit_form and
.../portal_skins/content/full_metadata_edit_form ) force Zope to marshall
both a subject:lines and a subject:list into one subject list. You can end
up with a list that contains a list containing a null string. I saw a line
in ListCriterion.py that does something like this:

   import operator
        value = tuple(filter(operator.truth, self.value))

...which would filter out "null" lists, but wouldn't strip non-null strings.
Maybe a combination of both is needed.

The fix would go somewhere in metadata_edit. Aha! this is a skin
(.../portal_skins/content/metadata_edit) so you can easily fix it locally.


-- Loren


> From: zope-cmf-admin@zope.org [mailto:zope-cmf-admin@zope.org]On Behalf
>
> > From: "Loren Stafford" <lstafford@morphics.com>
> >>>>
> >>> This is a familiar problem to anyone who has worked with Lines
> >> textareas in
> >>> Zope, and most of us have developed workarounds. I think CMF needs to
> >>> include a workaround too.
>
> What would be the workaround?
>
>