[Zope] Newbie: Python:Path Troubles

Rebecca.R.Hepper@seagate.com Rebecca.R.Hepper@seagate.com
Fri, 12 Jul 2002 10:57:31 -0500


Thanks much for the reply.

When I try to use restrictedTraverse or unrestrictedTraverse in my python
script I always get the error:

Error Type:  NameError
Error Value:  global name 'restrictedTraverse' is not defined

I did spell it correctly and mine looks like the examples I find on the
net.  What does this error mean?



                                                                                                                   
                    Dieter Maurer                                                                                  
                    <dieter@hands        To:     Rebecca.R.Hepper@seagate.com                                      
                    hake.de>             cc:     zope@zope.org                                                     
                    Sent by:             Subject:     Re: [Zope] Newbie:  Python:Path Troubles                     
                    zope-admin@zo                                                                                  
                    pe.org                                                                                         
                    No Phone Info                                                                                  
                    Available                                                                                      
                                                                                                                   
                    07/11/2002                                                                                     
                    02:41 PM                                                                                       
                                                                                                                   
                                                                                                                   




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


_______________________________________________
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 )