def add(self, content): """See zope.browser.interfaces.IAdding """ container = self.context name = self.contentName chooser = INameChooser(container) # check precondition checkObject(container, name, content) if IContainerNamesContainer.providedBy(container): # The container picks its own names. # We need to ask it to pick one. name = chooser.chooseName(self.contentName or '', content) else: request = self.request name = request.get('add_input_name', name) if name is None: name = chooser.chooseName(self.contentName or '', content) elif name == '': name = chooser.chooseName('', content) else: # Invoke the name chooser even when we have a # name. It'll do useful things with it like converting # the incoming unicode to an ASCII string. name = chooser.chooseName(name, content) content.id = name container._setObject(name, content) self.contentName = name # Set the added object Name return container._getOb(name)
def add(self, content): """See zope.browser.interfaces.IAdding """ container = self.context name = self.contentName chooser = INameChooser(container) # check precondition checkObject(container, name, content) if IContainerNamesContainer.providedBy(container): # The container picks its own names. # We need to ask it to pick one. name = chooser.chooseName(self.contentName or '', content) else: request = self.request name = request.get('add_input_name', name) if name is None: name = chooser.chooseName(self.contentName or '', content) elif name == '': name = chooser.chooseName('', content) else: # Invoke the name chooser even when we have a # name. It'll do useful things with it like converting # the incoming unicode to an ASCII string. name = chooser.chooseName(name, content) content.id = name container._setObject(name, content) self.contentName = name # Set the added object Name return container._getOb(name)
def setupCopyPasteMove(self): hasContent = self.hasContent if self.allowCut: self.supportsCut = hasContent if self.allowCopy: self.supportsCopy = hasContent if self.allowDelete: self.supportsDelete = hasContent if self.allowPaste: self.supportsPaste = self.hasClipboardContents if self.allowRename: self.supportsRename = (hasContent and self.supportsCut and not IContainerNamesContainer.providedBy(self.context))
def nameAllowed(self): """Return whether names can be input by the user.""" return not IContainerNamesContainer.providedBy(self.context)
def nameAllowed(self): """Return whether names can be input by the user.""" return not IContainerNamesContainer.providedBy(self.context)