[Zope] Dealing with Dictionaries

Martijn Pieters mj@digicool.com
Sat, 4 Mar 2000 14:18:41 +0100


From: "James W. Howe" <jwh@allencreek.com>
> At 08:21 AM 3/2/00 -0600, Evan Simpson wrote:
> >----- Original Message -----
> >From: James W. Howe <jwh@allencreek.com>
> > > Here's what I've got.  First, I have a DTMLMethod named
> >creditCardsAccepted
> >
> > > I then have a method called creditCardSelections which is defined as
> >follows:
> > >
> > > <dtml-return "creditCardsAccepted.keys()">
> >
> >Try <dtml-return "creditCardsAccepted().keys()">
>
>
> Followup,
>
> I just realized that I had two definitions of "creditCardsAccepted".  One
> was defined inside my ZClass, and one was defined in the folder containing
> the ZClass.  The one in the container was just answering a list.  When I
> changed that one to answer a dictionary things worked.  I then simply
> deleted the DTMLMethod in the containing folder and now I get a name
> error.  Now I'm really confused.  After deleting the higher level method,
I
> now have the creditCardsAccepted and the creditCardSelections both in the
> same folder.  It seems, however, that the creditCardSelections cannot see
> the sibling method.
>
> I'm clearly overlooking something.

You'll have to call your DTML Method in a special way. When caling a DTML
object with <dtml-var name=DTMLMethodOrObject> this is automatically taken
care of. but when using it in the above way, you have to do this by hand:

  <dtml-in "creditCardSelections(_, _.None, *other arguments*)">

You now pass in the namespace as well, so your DTML knows how to access
other Zope Objects. This _will_ change in the future, BTW, this will be
automated for various reasons. You then won't have to think about all this
anymore.

Have alook at the following How-To, and espcecially the list referrenced at
the bottom of it:

  http://www.zope.org/Members/Pam/DTMLScripting

They will introduce you to the more advanced ideas of DTML scripting.

Martijn Pieters
| Software Engineer    mailto:mj@digicool.com
| Digital Creations  http://www.digicool.com/
| Creators of Zope       http://www.zope.org/
|   The Open Source Web Application Server
---------------------------------------------