Re: [Zope] restrictedTraverse([''])

2005-05-24 Thread Hong Yuan

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([''])

2005-05-24 Thread Lennart Regebro
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.

-- 
Lennart Regebro, Nuxeo http://www.nuxeo.com/
CPS Content Management http://www.cps-project.org/
___
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! :-)

2000-09-15 Thread Andrew Kenneth Milton

+---[ Dennis Nichols ]--
| At 9/15/00 10:05 AM, Chris Withers wrote:
| >So:
| >
| >
| >
| >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  ...



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 )




Re: [Zope] restrictedTraverse - yay! :-)

2000-09-15 Thread Dennis Nichols

At 9/15/00 10:05 AM, Chris Withers wrote:
>So:
>
>
>
>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  ...


--
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! :-)

2000-09-15 Thread Steve Alexander

Dennis Nichols wrote:
> 
> At 9/15/00 10:05 AM, Chris Withers wrote:
> >So:
> >
> >
> >
> >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  "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:



--
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! :-)

2000-09-15 Thread Steve Alexander

Chris Withers wrote:
> 
> PS: Has your patch to allow &dtl.url-/folder/object; made any progress
> into the Zope core yet?

That's part of another proposal now. I really don't like having '/'
characters in SGML entities. I have this heretical view that DTML should
try to conform to SGML where possible.

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