Hello all, I've got a content type that represents a certain type of data file, a VR2File. When a VR2File is added to the portal, I've been using a registered handler for IObjectInitializedEvent to parse the data from the uploaded file and insert the results into an external relational database.
Up until now, when an error was raised in the parser code, I've been allowing it to bubble up and abort the zope transaction, so that neither the VR2File object, nor the rows in the external database get preserved. This works functionally, but has a major drawback. The problem is that when the parsing of a VR2File fails, my users are confronted with an unfriendly error message (the standard 'call your administrator with this code' message). In certain cases I would prefer it if the creation of the VR2File object were aborted and the user were returned to the Edit template, as if a validator on the form had failed. I've been snooping around in Archetypes, trying to figure out how plone's built-in types handle this sort of thing, and I've discovered the plone_utils.addPortalMessage() method. This works a neat trick to get my human readable strings into the portal status system. But if I re-raise my parser error, they still end up at the default error message template. Worse yet, if I don't re-raise the parser error, the plone-bound VR2File object is created, but none of the data parsed ends up in the external database. I am beginning to suspect that the post-creation event handler is _not_ the right place to have located my parser code. I would like to use parser errors to work similarly to validation errors in a standard AT content type. That is to say, I'd like them to abort the creation of the VR2File object and return the user to the edit page, with a portal status message that tells them what went wrong. Is this possible from a handler of IObjectInitializedEvent? If not, what is a better hook upon which to hang my parsing code. I'm a bit stumped about where I might inject that process in the standard AT form processing and object creation code. I welcome any and all suggestions, Cris -- View this message in context: http://n2.nabble.com/Help-with-IObjectInitializedEvent-handler-tp2519367p2519367.html Sent from the Product Developers mailing list archive at Nabble.com. _______________________________________________ Product-Developers mailing list [email protected] http://lists.plone.org/mailman/listinfo/product-developers
