Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6117181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:17:28+00:00 2026-05-23T15:17:28+00:00

I have: try: path1 = /Plone/s/a path2 = 2011/07/07 #The path to traverse becomes

  • 0

I have:

try:
    path1 = /Plone/s/a
    path2 = 2011/07/07
    #The path to traverse becomes /Plone/s/a/2011/07/07/. From
    #Plone to last 07, they are normal Folders.
    ob = self.portal.unrestrictedTraverse('%s/%s/' % (path1, path2))
    print ob
except AtributeError:
    #do something
    pass

/Plone/s/a/2011/07/07/ doesn’t exist. /Plone/s/a/2011/07/ exists. The code above is supposed to give an AtributeError, but I get /Plone/s/a/2011/07/ object instead. It prints:

<ATFolder at /Plone/s/a/2011/07 used for /Plone/s/a/2011/07>

I don’t want to get a “similar” result from the traverse, this is wrong. I need specifically /Plone/s/a/2011/07/07/. If it doesn’t exists, I want to catch the exception .

Which other approaches can I use to see if there’s an object exactly at /Plone/s/a/2011/07/07/, and not close enough like /Plone/s/a/2011/07/?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:17:29+00:00Added an answer on May 23, 2026 at 3:17 pm

    You hit acquisition.

    You want to get the ’07’ element/property/attribute of the ’07’ folder. But this last one doesn’t have a sub-object with that id. So , due to acquisition, the existing ’07’ folder asks to its parent element if it has a sub-object with the mentioned id, and of course, ‘2011’ folder has that element, the ’07’ one you are sitting on.

    This is a rough explanation of how acquisition works.

    Another example is this URL:
    http://plone.org/news/news/news/news/news/events

    The ‘events’ folder doesn’t really live in ‘news’ folder. And all those ‘news’ folders aren’t really there, but there is at least one ‘news’ folder living in plone.org root, and although it doesn’t have an ‘events’ folder, its parent (plone.org again) does.

    Here you have some references:

    • http://plone.org/documentation/glossary/acquisition
    • http://docs.zope.org/zope2/zope2book/Acquisition.html

    If you want to make sure an element/property/attribute is really part of the parent element you should use aq_base from Acquisition:

    from Acquisition import aq_base
    
    plone = aq_base(self.portal.Plone)
    s = aq_base(getattr(plone, 's'))
    a = aq_base(getattr(s, 'a'))
    year = aq_base(getattr(a, '2011'))
    month = aq_base(getattr(year, '07'))
    day = aq_base(getattr(month, '07'))
    

    aq_base strips the acquisition chain from the element so no acquisition will be used to get its elements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have wanted to try GAE since launch, but coming from ASP .NET and
Let's say I have a list of sub paths such as <PropertyGroup> <subPaths>$(path1)\**\*; $(path2)\**\*;
i have try refox and see how eazy my EXE to be disassembled. the
I have try to set icon for my App in the xCode. In the
In my services all exposed methods have: try { // the method core is
Is it considered bad practice to have multiple try's in one method and structure
We have following code: try { // some code throwing MyException } catch (MyException
I have started to try out noSQL databases now and are currently testing out
I have this code try { //AN EXCEPTION IS GENERATED HERE!!! } catch {
Hi I have a file try.SPEC. This file contains a word Version: 1.0.0.1 .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.