def add(self, content): """See zope.app.container.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) chooser.checkName(name, content) container[name] = content self.contentName = name # Set the added object Name return container[name]
def add(self, content): """See zope.app.container.interfaces.IAdding """ container = self.context name = self.contentName chooser = INameChooser(container) # check precondition checkObject(container, name, content) if IContainerNamesContainer.providedBy(container): # The container picks it's 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, container) 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.app.container.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) chooser.checkName(name, content) container[name] = content self.contentName = name # Set the added object Name return container[name]
def allowRename(self): if IRenameNotAllowed.providedBy(self.context): return False container = self.context.__parent__ return (IWriteContainer.providedBy(container) and not IContainerNamesContainer.providedBy(container) and canAccess(container, '__setitem__'))
def nameAllowed(self): """Return whether names can be input by the user.""" context = self.context if IContentType.providedBy(context): context = context.context if IAdding.providedBy(context): context = context.context if IWriteContainer.providedBy(context): return not IContainerNamesContainer.providedBy(context) else: return False
def fields(self): if self.step.name != 'content' or \ not isinstance(self.step, ContentStep): return Fields() context = self.context if not ISite.providedBy(context): if IRenameNotAllowed.providedBy(context): return Fields() if not IContentNamesContainer.providedBy(context): location = context.__parent__ if IWriteContainer.providedBy(location) and \ not IContainerNamesContainer.providedBy(location): return Fields(IContentRenameForm) return Fields()
def addObject(self): request = self.request if IContainerNamesContainer.providedBy(self.context): new = "" else: new = request["new_value"] adding = zapi.queryMultiAdapter((self.context, self.request), name="+") if adding is None: adding = Adding(self.context, request) else: # Set up context so that the adding can build a url # if the type name names a view. # Note that we can't so this for the "adding is None" case # above, because there is no "+" view. adding.__parent__ = self.context adding.__name__ = '+' adding.action(request['type_name'], new)
def addObject(self): request = self.request if IContainerNamesContainer.providedBy(self.context): new = "" else: new = request["new_value"] adding = queryMultiAdapter((self.context, self.request), name="+") if adding is None: adding = Adding(self.context, request) else: # Set up context so that the adding can build a url # if the type name names a view. # Note that we can't so this for the "adding is None" case # above, because there is no "+" view. adding.__parent__ = self.context adding.__name__ = '+' adding.action(request['type_name'], new)
def _normalListContentsInfo(self): request = self.request self.specialButtons = ('type_name' in request or 'rename_ids' in request or ('container_rename_button' in request and request.get("ids")) or 'retitle_id' in request) self.normalButtons = not self.specialButtons info = map(self._extractContentInfo, self.context.items()) self.supportsCut = info self.supportsCopy = info self.supportsDelete = info self.supportsPaste = self.pasteable() self.supportsRename = ( self.supportsCut and not IContainerNamesContainer.providedBy(self.context)) return info
def __bind__(self, content, globalenviron, environ): clone = super(IdColumn, self).__bind__(content, globalenviron, environ) table = self.table copier = IObjectCopier(content, None) if copier is not None and copier.copyable() and \ canAccess(table.context, '__setitem__') and \ not IUncopyableContent.providedBy(content): copyable = True table.supportsCopy = True else: copyable = False moveable = False renameable = False deletable = False if not IUnremoveableContent.providedBy(content): mover = IObjectMover(content, None) if mover is not None and mover.moveable(): if not IUnpastableContent.providedBy(content): moveable = True table.supportsCut = True if not IRenameNotAllowed.providedBy(content): renameable = \ not IContainerNamesContainer.providedBy(self.context) if renameable: table.supportsRename = True if not IUnremoveableContent.providedBy(content) and \ checkPermission('zojax.DeleteContent', content): deletable = True table.supportsDelete = True clone.buttons = copyable or moveable or renameable or deletable return clone
def add(self, content, name=''): if not self.isAddable(): raise Unauthorized("Can't create '%s' instance"%self.name) context = self.container content = removeAllProxies(content) if IContentContainer.providedBy(context) or \ IContentNamesContainer.providedBy(content): chooser = INameChooser(context) if IContainerNamesContainer.providedBy(context): name = chooser.chooseName('', content) else: name = chooser.chooseName(name, content) chooser.checkName(name, content) self.checkObject(context, name, content) removeSecurityProxy(context)[name] = content return context[name] else: raise ValueError(_("Can't add content."))
def _normalListContentsInfo(self): request = self.request self.specialButtons = ( 'type_name' in request or 'rename_ids' in request or ('container_rename_button' in request and request.get("ids")) or 'retitle_id' in request ) self.normalButtons = not self.specialButtons info = map(self._extractContentInfo, self.context.items()) self.supportsCut = info self.supportsCopy = info self.supportsDelete = info self.supportsPaste = self.pasteable() self.supportsRename = ( self.supportsCut and not IContainerNamesContainer.providedBy(self.context) ) return info
def nameAllowed(self): """Return whether names can be input by the user.""" return not IContainerNamesContainer.providedBy(self.context)
def namesAccepted(self): return not IContainerNamesContainer.providedBy(self.context)