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

Dieter Maurer dieter@handshake.de
Fri, 7 Dec 2001 01:08:13 +0100


Tille, Andreas writes:
 > while now syntactically correct I was not able to solve my logical
 > problem, which is: Stripping a set of keywords of type 'lines' from
 > whitespace and removing blank lines.
 > ...
 > 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)
 > 
 > Unfortunately I see no effect for my changed keyword values.  Did I
 > something wrong?  Any suggestion how to debug this code?
You do not use the new value but the current value...

   Use "for keyword in value:" instead of "for keyword in save_keywords".


Dieter