On Wednesday 17 October 2001 11:27 am, Roger Erens allegedly wrote:
Hello all,
I've got this:
Root Folder --AddPlayer (DTML Method) --AddPlayerScript (Python Script) --Players (Folder) --Player1 (DTML Document) --Player2 (DTML Document) --...
To add a player (DTMLDocument) in the Players folder and then add a property to the newly created DTMLDocument I needed to take refuge to calling the Python script (as is shown in chapter 5 of the Zope Book). Could someone give me the 'DTML translation' of the script so that I can keep the functionality together in the AddPlayer DTMLMethod? I think I would need something like <dtml-call expr="Player3.manage_addProperty('Score', 0.00, 'float')"> but with something instead of the hardcoded 'Player3'.
This is the AddPlayer method: [snip] <dtml-with Players> <dtml-let NewPlayerID="'Player3'"> <dtml-call expr="manage_addDTMLDocument(id=NewPlayerID,title='nonsense')"> <dtml-call expr="AddPlayerScript(NewPlayerID)"> </dtml-let> </dtml-with> [snip]
And this is the AddPlayerScript (called with the parameter playerID): [snip] doc=getattr(context,playerID) doc.manage_addProperty('Score', 0.00, 'float') [snip]
PS: Yes, in the long run, I *will* put all the functionality in a Pythonscript and skip the DTMLmethod alltogether. First I want to understand this stuff.
Try this in place of the Py script call: <dtml-call expr="_.getitem(NewPlayerID).manage_addProperty('Score', 0.00, 'float')"> If you need to add multiple properties, wrap them in a "with" tag: <dtml-with expr="_.getitem(NewPlayerID)"> <dtml-call expr="manage_addProperty(...)"> <dtml-call expr="manage_addProperty(...)"> <dtml-call expr="manage_addProperty(...)"> ... </dtml-with> hth, /---------------------------------------------------\ Casey Duncan, Sr. Web Developer National Legal Aid and Defender Association c.duncan@nlada.org \---------------------------------------------------/