def ghostFactory(container, id, haunted_object): """add new ghost to container container: container to add ghost to (must be acquisition wrapped) id: (str) id for new ghost in container haunted_object: object to be haunted (ghosted), acquisition wrapped returns created ghost actual ghost created depends on haunted object on IContainer a GhostFolder is created on IVersionedContent a Ghost is created willem suggested to call this function electricChair, but well... """ addProduct = container.manage_addProduct['Silva'] content_url = '/'.join(haunted_object.getPhysicalPath()) if IContainer.providedBy(haunted_object): factory = addProduct.manage_addGhostFolder elif IContent.providedBy(haunted_object): if haunted_object.meta_type == 'Silva Ghost': version = getLastVersionFromGhost(haunted_object) content_url = version.get_haunted_url() factory = addProduct.manage_addGhost factory(id, content_url) ghost = getattr(container, id) return ghost
def canBeHaunted(to_be_haunted): if IGhost.providedBy(to_be_haunted): return 0 if (IContainer.providedBy(to_be_haunted) or IContent.providedBy(to_be_haunted)): return 1 return 0 #END
def get_link_status(self, content=None): """return an error code if this version of the ghost is broken. returning None means the ghost is Ok. """ if content is None: content = self.get_haunted_unrestricted(check=0) if self._content_path is None: return self.LINK_EMPTY if content is None: return self.LINK_VOID if IContainer.providedBy(content): return self.LINK_FOLDER if not IContent.providedBy(content): return self.LINK_NO_CONTENT if IGhost.providedBy(content): return self.LINK_GHOST return self.LINK_OK