[Grok-dev] Frustrating error when trying to add grok app instances...

Sebastian Ware sebastian at urbantalk.se
Tue Sep 14 13:03:16 EDT 2010


We have a Grokproject that has had several apps created and deleted. Now it refuses to create ned instances from the Grok server admin. We have tried stop sever > delete Data.fs > start server but we keep on getting the same error in the UI:

  Name `sdfdsf` already in use. Please choose another name

Regardless of what name we choose. Note, no error in the console, only an error in the UI. The app-code has been updated.

I have looked in the code and found this:

        try:
            new_app = app()
            grok.notify(grok.ObjectCreatedEvent(new_app))
            self.context.root[name] = new_app
            self.flash(u'Added %s `%s`.' % (application, name))
        except DuplicationError:
            self.flash(u'Name `%s` already in use. '
                       u'Please choose another name.' % (name,))

But might some other error when creating the app raise a DuplicationError? In which case this is hidden by catching the exception. It would be nicer to have:

        if self.context.root.has_key(name):
            self.flash(u'Name `%s` already in use. '
                       u'Please choose another name.' % (name,))
	else:
            new_app = app()
            grok.notify(grok.ObjectCreatedEvent(new_app))
            self.context.root[name] = new_app
            self.flash(u'Added %s `%s`.' % (application, name))

Thus exposing the potential error in the application code.

Mvh Sebastian




More information about the Grok-dev mailing list