[Grok-dev] Re: applyChanges and add forms

Martijn Faassen faassen at startifact.com
Mon Apr 16 17:04:51 EDT 2007

On 4/16/07, Philipp von Weitershausen <philipp at weitershausen.de> wrote:
> >> Do we want to do that in AddForm at all? AddForm after all creates the
> >> object and already (presumably) triggers an IObjectAdded event. Doing
> >> an IObjectModified event straight afterward would be doing things
> >> twice. Sounds like applyData in add forms want to do the real minimum
> >> to just set attributes based on the schema.

> I just realized that it would be useful to have applyData send an
> IObjectModifiedEvent all the time. Let's say you have the following add
> form action:
>      @grok.action('Add entry')
>      def add(self, **data):
>          self.context['ellie'] = ellie = Mammoth()
>          applyData(ellie, **data)
> The first line of the method body would trigger an IObjectAddedEvent,
> causing the object to be added to a catalog index, for example. The
> second line would modify the object, but not send an appropriate event
> to update the index.
> I think we want to send that event.

Good point.

However.. What if do the following:

       @grok.action('Add entry')
       def add(self, **data):
          ellie = Mammoth()
          self.applyData(ellie, **data)
          self.context['ellie'] =ellie

If the catalog is in use, we'd get a modified for an object that's not
yet given an intid. What happens then? We need some tests for this. A
test can clarify this.



More information about the Grok-dev mailing list