[Zope3-dev] Nasty bugs

Jim Fulton jim@zope.com
Wed, 20 Mar 2002 09:49:01 -0500


Guido van Rossum wrote:
> 
> I wondered, "why does the z3 root view display a broken image for
> Folders?"

Because icon support hasn't been implemented yet. :) Ditto for the
"title" part of the display.
 
> There's no single answer.  I found several bugs.  I don't know how to
> fix them.
> 
> (1) The page template used,
>     Zope3/lib/python/Zope/App/OFS/Folder/main.pt
>     contains this text:
> 
>           <img alt="Folder" src="../../ZMI/www/folder_icon.gif"
>                tal:condition="info/url"
>                tal:attributes="src info/url" />
> 
>     which I believe is a cut-and-paste error, and should really be
> 
>           <img alt="Folder" src="../../ZMI/www/folder_icon.gif"
>                tal:condition="info/icon"
>                tal:attributes="src info/icon" />

You are right about the typo, however, the ultimate working code
is likely to look much different. I started adding icon support
several weeks ago. Among other things, this led to adding resources, 
since icons are resources.

For now, we should just take this out of the contents view. I should
probably hand off my partial icon work to someone else.


> (2) When I fixed that in my copy, I got a traceback, ending in
>     "TypeError: len() of unsized object" in method evaluateBoolean()
>     in class Context in module TALES, file
>     Zope3/lib/python/Zope/PageTemplate/TALES.py (sorry, lost the lineno).
>     Casual printing of the evaluation outcome showed that it was doing
>     "not not None", which shouldn't trigger this error.
>     Printing of its type showed that it's really a wrapper for None,
>     and that using it in a Boolean context causes this error.
>     Two questions come up:
> 
>     (2a) Why would None need to be wrapped?

The reason an object would need to be wrapped is if someone wanted 
to know how it was obtained. There are a number of reasons that
someone might do that:

  - To do security Checks, although this doesn't apply to basic objects
    (whatever they are;), like None and numbers, and strings, that
    can't have meta-data needed for security checks.

  - Generating URLs. I suppose we don't want to be able to generate 
    urls to basic objects.

  - ???

What is actually doing the wrapping here? ZPT path expressions?
 
>     (2b) Why can't I use a wrapped None in a Boolean context?

It's a bug, as I think you've figured out.

...

> I could fix the bug in (1), but then the cure would be worse than
> the problem (you'd get a traceback from the front page instead of a
> broken image icon).
> 
> Please advise.

1 should be fixed by not showing the icon (or the title) for now. :)

Jim

--
Jim Fulton           mailto:jim@zope.com       Python Powered!        
CTO                  (888) 344-4332            http://www.python.org  
Zope Corporation     http://www.zope.com       http://www.zope.org