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? -- 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: hongyuan@homemaster.cn
On 5/24/05, Hong Yuan <hongyuan@homemaster.cn> 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/
Thanks very much for the clarification. Lennart Regebro wrote:
On 5/24/05, Hong Yuan <hongyuan@homemaster.cn> 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: hongyuan@homemaster.cn
participants (2)
-
Hong Yuan -
Lennart Regebro