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:

> > 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
Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to