[Zope] Passing parameters using DTML

Paul Winkler pw_lists at slinkp.com
Fri Jun 17 19:46:36 EDT 2005


On Fri, Jun 17, 2005 at 11:25:30PM +0100, John Poltorak wrote:
> This is what I have:-
> 
> <dtml-var expr="testlist(parm='myobjectname')">
> 
> I wish to get 'myobjectname' into this line in 'testlist' which is marked
> with *********
> 
> python:here.parse_file(file=context.******,sepr=',',clone=1)"> 
>
 
> There must be a simple way of doing this, but I haven't come across an 
> example of it and I've spent most of the day on it.

OK, I repeat my earlier suggestion:
  
> > Hint 1: Look at that expression from left to right.
> > Hint 2: Think about what "context.options" means.

Here's another clue: 
You are not really having a DTML problem. 
You are not really having a ZPT problem.
You are not even really having a Zope problem.
You are having a python problem.

The problem is:  given an object, foo, and an arbitrary string that 
identifies an attribute of foo, how do you get at that attribute?

There is a built-in python function that exists for exactly
this purpose.  Read about the getattr() function here:
http://python.org/doc/2.3.5/lib/built-in-funcs.html

> > In general, if you have not, you really should read the whole of 
> > http://www.plope.com/Books/2_7Edition/BasicScripting.stx
> > and  http://www.plope.com/Books/2_7Edition/ScriptingZope.stx
> > ... not just once but several times :-)
> 
> There is too much to read and understand. Much of it only ever makes any 
> sense in retrospect. Manuals are not a very useful way of learning how to 
> do something

(resists urge to rant)

Look - it doesn't have to all make sense on the first read, but
eventually it starts to click. If you won't even read it at all, you're
screwed before you begin.
 
-- 

Paul Winkler
http://www.slinkp.com


More information about the Zope mailing list