def _purgeCustomMenu(self, context):
     """Remove the interface and annotation from an object
     """
     if ICustomMenuEnabled.providedBy(context):
         annotation = ICustomMenuFactoriesAssignment(context)
         annotation.remove()
         noLongerProvides(context, ICustomMenuEnabled)
         context.reindexObject(idxs=["object_provides"])
 def _initCustomMenuInheritProperty(self, context, node):
     """Enable the Custom Menu and set the inherit property in the context
     """
     if node.getAttribute("name").lower() == "inherit":
         inherit = self._convertToBoolean(self._getNodeText(node))
         # set the inherit property in the container
         annotation = ICustomMenuFactoriesAssignment(context)
         alsoProvides(context, ICustomMenuEnabled)
         if not inherit:
             annotation.setInherit(False)
         context.reindexObject(idxs=["object_provides"])
    def _initCustomMenuNode(self, context, node):
        """Create a new menu entry and add it into the context
        """
        menuElement = {
            "element-id": "",
            "element-name": "",
            "element-descr": "",
            "icon-tales": "",
            "condition-tales": "",
            "element-tales": "",
        }

        for child in node.childNodes:
            if child.nodeName.lower() == "property":
                name = child.getAttribute("name").lower()
                if name in menuElement:
                    menuElement[name] = self._getNodeText(child)
        # TODO
        # self._validateCustomMenuElement(menuElement)

        context = ICustomMenuFactoriesAssignment(context)
        context.addMenuEntry(menuElement)
    def _exporNodeSettings(self, obj, node):
        """Export the object settings into a node
        """
        annotation = ICustomMenuFactoriesAssignment(obj)
        property = self._doc.createElement("property")
        property.setAttribute("name", "inherit")
        text = self._doc.createTextNode(unicode(annotation.inherit))
        property.appendChild(text)
        node.appendChild(property)

        for entry in annotation.listMenuEntries():
            custommenu = self._doc.createElement("custommenu")
            for name, value in entry.iteritems():
                if name != "index":
                    property = self._doc.createElement("property")
                    property.setAttribute("name", name)
                    text = self._doc.createTextNode(value)
                    property.appendChild(text)
                    custommenu.appendChild(property)

            node.appendChild(custommenu)

        return node