You are not logged in Log in Join
You are here: Home » Members » karl » fakePublishFolder » fakePublish.py » View Document

Log in
Name

Password

 

fakePublish.py

""" fakePublish.py """

class FakePublisher:
    "class for following the publishing process for an object"

    def __init__(self, obj):
        self.obj = obj
        self.pPath = obj.getPhysicalPath()
        self.pRoot = obj.getPhysicalRoot()
        self.descStr = ""
        for i in range(1, len(self.pPath)+1):
            self.descStr = self.descStr + self.getToChild(i)

    def getToChild(self, i):
        "What is the relation between the ith obj & its parent?"
        parentObj = self.pRoot.unrestrictedTraverse(self.pPath[0:i])
        parentId = self.pPath[i-1]
        parentName = parentObj.__class__.__name__
        if i < len(self.pPath):
            childObj = self.pRoot.unrestrictedTraverse(self.pPath[0:i+1])
            childId = self.pPath[i]
        else:
            childObj = None
            childId = None
        retStr = parentId + " (" + parentName + ")"
        if childObj:
            if not hasattr(parentObj, childId):
                # not there, or one of the few more complex publishing methods
                retStr = retStr + " doesn't contain in a way we know: " + \
                         childId + ". "
            else:
                if childId in dir(parentObj): # direct containment.
                    retStr = retStr + " contains: " + childId + ". "
                elif childId in parentObj.__class__.__dict__.keys(): # class meth
                    retStr = retStr + " method: " + \
                             childId + ". "
                else:
                    retStr = retStr + " eh? " + childId
        return retStr