!!! Listings aus dem Artikel "Keulenschwinger" !!! von Jan Ulrich Hasecke und Uli Fouquet !!! in iX 3/08. S. 156 !!! Listing 1: Grok-Projekt anlegen $ grokproject GrokIMDB Enter user (Name of an initial administrator user): grok Enter passwd (Password for the initial administrator user): grok Enter eggs_dir (Location where zc.buildout will look for and place \ packages) ['/home/user1/buildout-eggs']: Creating directory ./GrokIMDB Downloading zc.buildout... Invoking zc.buildout... $ !!! Listing 2: Interface IMovie class IMovie(Interface): """Infos about a movie. """ id = schema.TextLine(title=u'IMDb ID', required=False) title = schema.TextLine(title=u'Title', required=False) year = schema.Int(title=u'Year', required=False) summary = schema.Text(title=u'Summary', required=False) !!! Listing 3: Film-Formular class AddMovie(grok.AddForm): grok.context(GrokIMDB) form_fields = grok.AutoFields(IMovie) @grok.action("Add movie") def add(self, **data): movie = Movie() self.applyData(movie, **data) self.context[str(data['id'])] = movie self.redirect(self.url(movie)) !!! Listing 4: Bearbeitungsformular class EditMovie(grok.EditForm): grok.context(IMovie) grok.name('edit') form_fields = grok.AutoFields(IMovie) @grok.action("Apply changes") def applyChanges(self, **data): self.applyData(self.context, **data) @grok.action("Return to index") def returnToIndex(self, **data): self.applyData(self.context, **data) self.redirect(self.url(self.context.__parent__)) !!! Listing 5: Löschfunktion class DeleteMovie(grok.View): grok.context(GrokIMDB) grok.name('delete') def update(self, id): del self.context[id] def render(self): self.redirect(self.url(self.context)) !!! Listing 6: Indexdatei

Welcome to your GrokIMDB!

Your movies:

Add a movie