returning a dtml variable from a python expression
A simple question I have a variable that is returned from an sql query as <dtml-var id> I wish to include this in a python expression to create a photofolder or photoimage. When used as <dtml-call expr="manage_addProduct['Photo'].manage_addPhotoFolder(id='12345', title='')"> this works. but if used within <dtml-in createfolder size=50 start=query_start> <dtml-call expr="manage_addProduct['Photo'].manage_addPhotoFolder(id = '<dtml-var id>', title= '' )"> </dtml-in> I get Error Type: AttributeError Error Value: _setObject File C:\Program Files\WebSite\lib\python\DocumentTemplate\DT_Util.py, line 230, in eval (Object: manage_addProduct['Photo'].manage_addPhotoFolder(id = '<dtml-var id>', title= '' )) (Info: manage_addProduct) File <string>, line 2, in f (Object: guarded_getitem) What is the correct way to do this? Thanks for any help
DTML Rule # 1 - No DTML within DTML So you can't say <dtml-call expr="manage_addProduct['Photo'].manage_addPhotoFolder(id = '<dtml-var id>', title= '' )"> but you don't need to, since you can say <dtml-call expr="manage_addProduct['Photo'].manage_addPhotoFolder(id = id, title= '' )"> Remember, the DTML value is NOT named <dtml-var id> (as you put it), the "dtml-var" is just there to render it (write it into the resulting document). The name of the variable is just "id". Wouldn't an attribute called "id" collide with normal id properties? Better to call it something else, I would think. If it's coming from an sql query you can call it pretty near anything you like. Cheers, Tom P [Lester Cram] A simple question I have a variable that is returned from an sql query as <dtml-var id> I wish to include this in a python expression to create a photofolder or photoimage. When used as <dtml-call expr="manage_addProduct['Photo'].manage_addPhotoFolder(id='12345', title='')"> this works. but if used within <dtml-in createfolder size=50 start=query_start> <dtml-call expr="manage_addProduct['Photo'].manage_addPhotoFolder(id = '<dtml-var id>', title= '' )"> </dtml-in> I get Error Type: AttributeError Error Value: _setObject File C:\Program Files\WebSite\lib\python\DocumentTemplate\DT_Util.py, line 230, in eval (Object: manage_addProduct['Photo'].manage_addPhotoFolder(id = '<dtml-var id>', title= '' )) (Info: manage_addProduct) File <string>, line 2, in f (Object: guarded_getitem) What is the correct way to do this? Thanks for any help _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (2)
-
Lester Cram -
Thomas B. Passin