Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Pickels 75 posts 108 karma points
    Dec 09, 2010 @ 18:31
    Pickels
    0

    Children of Media node missing properties?

    I know the title is a little weird but I'll try and explain the problem.

    Lets say you have a property from a currentPage that returns and id from a media node.

    First you check if it's a folder.

    def _is_folder( node ):
        return node.ContentType.Text == 'Folder

    So far so good. Next what I want to do is loop all the children and return all the images

    media = Media( some_id )

    if _is_folder( media ):
        for item in media.Children:
            if item.ContentType.Text == 'Image':
                pass

    This will throw an Object reference not set to an instance of an object on the ContentType property.

    It's a little weird because when I check the type of 'item' it says it's a Media object. 

    To fix this I can do:

    for item in media.Children:
        item = Media( item.Id )
    

    So in other words instantiate a new Media object using the Id of an other Media object. 

    I find this weird and maybe it's a bug? I think I had the same with Node, that the nodes the .Children property returns aren't complete and are missing properties them self.

  • Jonas Eriksson 930 posts 1825 karma points
    Dec 10, 2010 @ 07:30
    Jonas Eriksson
    0

    Hi! Is this happening on v 4.52?

    Regards

    Jonas

  • Pickels 75 posts 108 karma points
    Dec 10, 2010 @ 09:19
    Pickels
    0

    Yep.

Please Sign in or register to post replies

Write your reply to:

Draft