[Zope] Question about accessing properties of images

Dieter Maurer dieter@handshake.de
Sat, 23 Feb 2002 12:15:13 +0100


Hi Kevin,

Kevin Carlson writes:
 > Here you go -- hope this helps.  I'm running Zope 2.5 if that helps any.  A
 > little explanation about the structure of the site may help, too.
 > 
 > The pic object I have sent you is a thumbnail image of a much larger image.
 > The larger images reside in a subdirectory called "largepics" and have the
 > same names.  When a user clicks on one of the hyperlinks that is associated
 > with the pic object, I send the id of the pic object to a DTML method called
 > "photo_html". (All of this occurs in the folder containing the thumbnails).
 > This method displays the larger picture from the subdirectory and pulls the
 > description from thumbnail.  I put the site together this way so that I
 > could have an admin page to be able to type descriptions for multiple
 > thumbnail pictures at one time.
 > 
 > I also tried adding the description to the larger image object but had the
 > same type of results.
 > 
 > Thanks for your interest in looking at this.  I anxiously await your reply!
I imported your image, created the following DTML Method

	<dtml-var standard_html_header>
	<h2><dtml-var title_or_id> <dtml-var document_title></h2>
	<p>
	<dtml-var expr="_.getitem('01').desc">
	</p>
	<dtml-var standard_html_footer>

and viewed it. Of course, I saw the description.


I can see 2 potential problems causing your failure:

  1.  Your image's name is valid in URL's and DTML but not
      in Python expressions (where you are inside "...").
      Inside Python, "01" is not an object but the integer 1
      (the leading "0" is intepreted as "octal number").
      Integers do not have attributes.

      The "_.getitem" above accepts arbitrary names and
      looks them up transparently in the DTML namespace.
      (read the "Name lookup section" in

        <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html>

       when your want to learn more about namespaces and lookup).

  2.  Where you use "pic.desc", there may be "dtml-with" active
      (to facilitate access to the "largspics"). In this case,
      your "pic" may be the large image, not the thumbnail.

      In this case, you would probably use a nested "dtml-with"
      to access your thumbnail.

I expect, your problem is 1.


Dieter