Tim Hicks(e)k dio:
> Mikel Larreategi wrote:
>> Tim Hicks(e)k dio:
>>> Tim Knapp wrote:
>>>
>>>> I'll take your word for it on the getTopics change but in principle it
>>>> sounds fine.
>>> It might be worth double checking that.  Presumably the normalize
>>> method/function expects something string-ish.  ITopic objects have a
>>> __str__ method, but I don't know if that's (necessarily always) enough...
>>>
>>>
>> I also can reproduce this error. But I don't think that the proposed 
>> getTopics method is the solution.
>>
>> getTopics returns, in that context, all topics of the blog, so I just 
>> propose to add a to-unicode conversion there, as follows:
>>
>> [EMAIL PROTECTED]:/var/zope/instances/codesyntax/src/quills.app/quills/app$ 
>> svn diff topic.py
>> Index: topic.py
>> ===================================================================
>> --- topic.py (revision 74088)
>> +++ topic.py (working copy)
>> @@ -90,7 +90,7 @@
>>           if topic_images is None:
>>               return None
>>           normalizer = getUtility(IIDNormalizer)
>> -        keyword_id = normalizer.normalize(self.keywords[0])
>> +        keyword_id = normalizer.normalize(self.keywords[0].decode('utf-8'))
>>           # To check for the presence of the image, we want to limit 
>> ourselves to
>>           # unacquired objects, so we use aq_base.
>>           image = getattr(aq_base(topic_images), keyword_id, None)
> 
> That patch makes me more comfortable than the getTopics one.  Assuming 
> the .decode(...) call won't sometimes fail, then it looks good.  (I'm 
> always wary of string encoding stuff because I've seen it throw 
> incomprehensible-to-me errors before.)

AFAIK, Archetypes stores everything in utf-8 encoded strings, so it 
would be safe to do that encoding-operation.

According to decodes's docstring::

 >>> a = 'encodëd-string'
 >>> print a.decode.__doc__
S.decode([encoding[,errors]]) -> object

Decodes S using the codec registered for encoding. encoding defaults
to the default encoding. errors may be given to set a different error
handling scheme. Default is 'strict' meaning that encoding errors raise
a UnicodeDecodeError. Other possible values are 'ignore' and 'replace'
as well as any other name registerd with codecs.register_error that is
able to handle UnicodeDecodeErrors.

So we can do .decode('utf-8', 'ignore') or .decode('replace') if we are 
not too sure of it.


> 
>> By the way, I tried to add a test of this bug in fixedBugs.rst, but I 
>> can't the tests run properly. How can I run those tests?
> 
> You should be able to use:
> 
>    bin/zopectl test -s Products.Quills
> 
> Doesn't that work?
> 

Ok, I was just looking at fixedBugs.rst in quills.app...


Mikel

-- 
Mikel Larreategi
[EMAIL PROTECTED]

CodeSyntax
Azitaingo Industrialdea 3 K
E-20600 Eibar
Tel: (+34) 943 82 17 80

_______________________________________________
quills-dev mailing list
[email protected]
http://lists.etria.com/cgi-bin/mailman/listinfo/quills-dev

Reply via email to