class EditMenuItem(MenuItem): menu(IDocumentActions) title(u'Bearbeiten') name('edit') order(20) @property def available(self): return getattr(self.context, 'isEditable', False)
class DeleteMenuItem(MenuItem): menu(IDocumentActions) title('Entfernen') name('delete') order(30) @property def available(self): return getattr(self.context, 'isDeletable', False)
class AddForm(Form): title(u'Erstellen') _finishedAdd = False @action(u'Speichern', identifier="uvcsite.add") def handleAdd(self): data, errors = self.extractData() if errors: self.flash('Es sind Fehler aufgetreten') return obj = self.createAndAdd(data) if obj is not None: # mark only as finished if we get the new object self._finishedAdd = True def createAndAdd(self, data): obj = self.create(data) notify(zope.lifecycleevent.ObjectCreatedEvent(obj)) self.add(obj) return obj def create(self, data): raise NotImplementedError def add(self, object): raise NotImplementedError def nextURL(self): raise NotImplementedError def render(self): if self._finishedAdd: raise HTTPFound(self.nextURL()) self.request.response.redirect(self.nextURL()) return "" return super(AddForm, self).render()
class PaintingOwner(grokcore.security.Role): grok.name('paint.PaintingOwner') grok.title('Painting Owner') grokcore.security.permissions('paint.ViewPainting', 'paint.EditPainting', 'paint.ErasePainting')
class DeleteForm(crud.Delete, Form): title(u'Entfernen') baseclass() actions = crud.Delete.actions title = u"Objekt bearbeiten"
class DisplayMenuItem(MenuItem): menu(IContextualActionsMenu) title(u'Anzeigen') name('index') order(10)
class DefaultView(DisplayForm): name('index') title(u'Anzeigen') baseclass() responseFactory = Response make_response = make_layout_response
class DisplayForm(crud.Display, Form): title(u'Anzeigen') baseclass()
class EditForm(crud.Edit, Form): title(u'Bearbeiten') baseclass() title = u"Objekt löschen"
class RoleWithI18nTitle(Role): grok.name('RoleWithI18nTitle') grok.title(_('RoleWithI18n')) grok.description(_('My role with i18n'))