Hello All, I am using Zope 2-5-1 and CMF-1.2. I am trying to use python:path in a html form to get a path name which I will pass to a python script and use the setDescription function on. I am not getting the python:path statement to work. If I print my python:path statement into a table header I get something like: "<PortalFolder instance at 90a24a0>" What I am doing wrong? I have pasted portions of my code below. I also attempted to use 'nocall' but didn't get that to work for me either. Thanks in advance! <table tal:define="myhere root/MyPortal/folderA"> <tr valign="top" align="left" tal:repeat="folders python:myhere.contentValues(filter ={'Type':'Folder'})"> <span tal:define="folderID folders/id"> <th tal:content="folders/title">Title</th> <td><input type="radio" name="folderTitle" value="folders" tal:attributes="value folders/title"></td> <!-- <th tal:content="python:path('root/MyPortal/folderA/%s' % folderID)"></th> --> <td><input type="hidden" name="folderPath" value="folderPath" tal:attributes="value python:path('root/MyPortal/folderA/%s' % folderID)"></td> </span> </tr> Then in the python script: folderPath.setDescription("This is my new description")
Rebecca.R.Hepper@seagate.com writes:
I am trying to use python:path in a html form to get a path name which I will pass to a python script and use the setDescription function on. What is the "path name"? Do you mean the "URL"?
... If I print my python:path statement into a table header I get something like: "<PortalFolder instance at 90a24a0>" ... <td><input type="hidden" name="folderPath" value="folderPath" tal:attributes="value python:path('root/MyPortal/folderA/%s' % folderID)"></td> This is exactly, how "path" should work:
It turns a path into an object, in this case into a "PortalFolder" object. As the generated HTML can only contain strings, ZPT calls the "str" method on the object. This results in "<PortalFolderI instance at ...>". What you need to do: Pass the path string itself as value of the hidden variable. Use "restrictedTraverse" in you Python Script to resolve it into an object. Call "setDescription" on this object. Dieter
participants (2)
-
Dieter Maurer -
Rebecca.R.Hepper@seagate.com