[Zope] Re: Changing Properties (Was: More product writing problems)

Tille, Andreas TilleA@rki.de
Fri, 7 Dec 2001 14:21:58 +0100 (CET)


On Fri, 7 Dec 2001, Dieter Maurer wrote:

>  > def _updateProperty(self, id, value):
>  >     ....
>  >     # Update the value of an existing property. If value
>  > #    Code was stolen from: /usr/lib/zope/lib/python/OFS/PropertyManager.py
>  >     # is a string, an attempt will be made to convert
>  >     # the value to the type of the existing property.
>  >     self._wrapperCheck(value)
>  >     if not self.hasProperty(id):
>  >         raise 'Bad Request', 'The property %s does not exist' % id
>  >     if type(value)==type(''):
>  >         proptype=self.getPropertyType(id) or 'string'
>  >         if type_converters.has_key(proptype):
>  >             value=type_converters[proptype](value)
>  >     if id == 'keywords' :                        # +
>  >         save_keywords=self.keywords              # +
>  >         self.keywords=[]                         # +
>  >         for keyword in save_keywords:            # +
>  >             keyword=keyword.strip()              # +
>  >             if keyword != '' :                   # +
>  >                self.keywords.append(keyword)     # +
>  >     else:
>  >         self._setPropValue(id, value)
>  >
>    Use "for keyword in value:" instead of "for keyword in save_keywords".
Uhm, there are errors and stupid errors.  Thanks for pointing to the
stupid error.  But unfortunately there seems to be another one, because
it does not work even if I use 'value' nor if I change the code to

    if id == 'keywords' :
        new_value=[]
        for keyword in value:
            keyword=keyword.strip()
            if keyword != '' :
               new_value.append(keyword)
        value=new_value
    self._setPropValue(id, value)

My suspection is that something goes wrong more generally (the
_updateProperty is just not called or the if condition might not
be true because any strange pre/or suffixes or something else).

So I'm looking for any suggestion how to debug the code efficiently.

If I would insert any 'print' statements or something else to which
data stream would they directed.  Would it be the STUPID_LOG_FILE or
something else or should I open a temporary file.  Which is the
method you use generally for such stuff?

Kind regards

         Andreas.