Re: [Zope] restrictedTraverse([''])
Thanks very much for the clarification. Lennart Regebro wrote: On 5/24/05, Hong Yuan [EMAIL PROTECTED] wrote: I happened to find that obj.restrictedTraverse(['']) returns the application object, instead of the object itself. This is quite unexpected, as both obj.restrictedTraverse('') and obj.restrictedTraverse([]) returns the object itself. Is this a bug or a feature? RestrictedTraverse on a list will assume it is a path of ids. restrictedTraverse on a string will assume it is a URL. A path of ids that starts with '' is a absolute path, just like a URL that starts with '/'. So, the path list [''] means the root/application object, just like '/' means the root/application object. However [] is an empty path, and is therefore the same as the URL ''. So, the above behaviour is expected and as defined. -- HONG Yuan Homemaster Trading Co., Ltd. No. 601, Bldg. 41, 288 Shuangyang Rd. (N) Shanghai 200433, P.R.C. Tel: +86 21 55056553 Fax: +86 21 55067325 E-mail: [EMAIL PROTECTED] ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] restrictedTraverse - yay! :-)
Dennis Nichols wrote: At 9/15/00 10:05 AM, Chris Withers wrote: So: dtml-var "restrictedTraverse('slash/delimited/path')" absolute_url will work as I expect it to? Well, I don't know what you expect :-) When I try to save such a construct with the handy-dandy Change button I get Document Template Parse Error Invalid attribute name, "absolute_url", for tag dtml-var "restrictedTraverse(choice)" absolute_url ... Yeah. That's right. There is no attrubute absolute_url. There is, however, a method absolute_url(). This should do what you expect: dtml-var "restrictedTraverse('slash/delimited/path').absolute_url()" -- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] restrictedTraverse - yay! :-)
At 9/15/00 10:05 AM, Chris Withers wrote: So: dtml-var "restrictedTraverse('slash/delimited/path')" absolute_url will work as I expect it to? Well, I don't know what you expect :-) When I try to save such a construct with the handy-dandy Change button I get Document Template Parse Error Invalid attribute name, "absolute_url", for tag dtml-var "restrictedTraverse(choice)" absolute_url ... -- Dennis Nichols [EMAIL PROTECTED] ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] restrictedTraverse - yay! :-)
+---[ Dennis Nichols ]-- | At 9/15/00 10:05 AM, Chris Withers wrote: | So: | | dtml-var "restrictedTraverse('slash/delimited/path')" absolute_url | | will work as I expect it to? | | Well, I don't know what you expect :-) When I try to save such a construct | with the handy-dandy Change button I get | | Document Template Parse Error | Invalid attribute name, "absolute_url", for tag dtml-var | "restrictedTraverse(choice)" absolute_url ... dtml-var "restrictedTraverse(choice).absolute_url()" I think is what is required. -- Totally Holistic Enterprises Internet| P:+61 7 3870 0066 | Andrew Milton The Internet (Aust) Pty Ltd | F:+61 7 3870 4477 | ACN: 082 081 472 ABN: 83 082 081 472 | M:+61 416 022 411 | Carpe Daemon PO Box 837 Indooroopilly QLD 4068|[EMAIL PROTECTED]| ___ Zope maillist - [EMAIL PROTECTED] 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 )