[Zope] eval() in dtml?

Jim Fulton jim@digicool.com
Sun, 06 Jun 1999 15:43:59 +0000


Alex Rice wrote:
> 
> Is eval() not available in DTML?

Yes, eval is not available as a function in DTML.

> What am I doing wrong here? 

You are using eval. ;)

> You can
> probably tell I'm new this
> 
> <!--#comment--> Create a new Folder, then a Doc in the new Folder.
> folderName and text are string which are submitted to this script.
> <!--#/comment-->
> 
> <!--#call "items.manage_addFolder( folderName )"-->
> <!--#call "eval('items.'+folderName+'.manage_addDTMLDocument(text)')"-->

You can use getattr here:

 <!--#call "_.getattr(items, folderName).manage_addDTMLDocument(
     id='something',
     file=text)"-->

Note that manage_addDTMLDocument requires you to specify an id.

Jim

--
Jim Fulton           mailto:jim@digicool.com
Technical Director   (540) 371-6909              Python Powered!
Digital Creations    http://www.digicool.com     http://www.python.org

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.