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 5979491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:39:59+00:00 2026-05-22T21:39:59+00:00

Suppose I have a content type, Folder, with 4 items. + MyObject – Child1

  • 0

Suppose I have a content type, Folder, with 4 items.

+ MyObject
 - Child1
 - Child2
 - Child3
 + Child4
  - Child5
 - Child6

Suppose I have another content type (let’s call it Alias). This Alias is mainly a reference to another object but folderish: it can contain a bunch of other aliases. I’m going to use --> to indicate this reference in the following tree representations.(“Reference” is mainly an attribute called “reference” that receives the UID from the target object).

Suppose MyAlias now references my MyObject.

+ MyAlias --> MyObject
 - (Nothing)

When referencing to MyObject, MyAlias doesn’t know that MyObject is a Folder, so the internal MyAlias children don’t exist. I need to loop through everyone, and create, manually, an Alias inside MyAlias, that is a reference (having the same structure) to MyObject children. A little tree showing what should happen:

+ MyAlias --> MyObject
 - Alias --> Child1
 - Alias --> Child2
 - Alias --> Child3
 + Alias --> Child4
  - Alias --> Child5
 - Alias --> Child6

I would like to know the best way to iterate through MyObject items, and create the same structure with another objects, using some kind of loop and using invokeFactory in a subscriber. In the end, I would have BOTH trees existing: one of the actual Folder and children, and another of references to this same Folder and children.

(Summarizing: something like collective.alias, but in a really primitive form, just folders an documents, since I can’t use collective.alias.)

  • 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-22T21:40:00+00:00Added an answer on May 22, 2026 at 9:40 pm

    The most elegant and Pythonic solution is to write a recursive generator. Assuming this is a method:

    def iter_preorder(self):
        yield self
        # check for folderishness here if a non-folderish
        # node may have children as well
        for x in self.children:
            for y in x.iter_preorder():
                yield y
    

    Then

    for x in tree.iter_preorder():
        do_action(x)
    

    This way, you don’t actually have to wrap your action into a function/callable and there’s no inversion of control.

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

Sidebar

Related Questions

Suppose i have the following 2 SQL tables: Foo Column DataType --------------------------- Title NVARCHAR(20)
Suppose I have a custom collection class that provides some internal thread synchronization. For
I am trying to build an application in which i have to stream the
I have an e-commerce package called Prestashop. They allow you to sell virtual products,
I have two files, one containing an array in PHP that is echo ed
I have this code: $reader = new DOMDocument(); $reader->loadHTML($shell); $xpath = new DomXPath($reader); $xpath->registerNamespace('html','http://www.w3.org/1999/xhtml');
Can jquery-ajax reload a div WITH DYNAMIC CONTENTS. For example if i have a
I've a document-based application powered by Core Data with an in-memory store. I have
I have Objective C code creating an NSUrlConnection as follows: //prepar request NSString *urlString
I have the following very simple Ext JS 4 script which is supposed to

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.