def renderLink(self, topic): """Render a href element.""" title = translate(topic.title, context=self.request, default=topic.title) if topic.parentPath: url = zapi.joinPath(topic.parentPath, topic.id) else: url = topic.id return '<a href="/++help++/%s">%s</a>\n' % (url, title)
def isExpanded(self, topic): if topic.parentPath: path = zapi.joinPath(topic.parentPath, topic.id) else: path = topic.id try: if zapi.getPath(self.context).startswith('/' + path): return True except: # TODO: fix it, functional test doesn't like zapi.getPath? ri pass return False
def cutObjects(self): """move objects specified in a list of object ids""" request = self.request ids = request.get('ids') if not ids: self.error = _("You didn't specify any ids to cut.") return container_path = zapi.getPath(self.context) # For each item, check that it can be moved; if so, save the # path of the object for later moving when a destination has # been selected; if not movable, provide an error message # explaining that the object can't be moved. items = [] for id in ids: ob = self.context[id] mover = IObjectMover(ob) if not mover.moveable(): m = {"name": id} title = getDCTitle(ob) if title: m["title"] = title self.error = _( "Object '${name}' (${title}) cannot be moved", mapping=m) else: self.error = _("Object '${name}' cannot be moved", mapping=m) return items.append(zapi.joinPath(container_path, id)) # store the requested operation in the principal annotations: clipboard = getPrincipalClipboard(self.request) clipboard.clearContents() clipboard.addItems('cut', items)