Mar 11, 2010
Careful with that ajax, Eugene
Ajax calls are an invaluable and powerful tool to deploy pleasant user interfaces, but some attention must be paid to avoid bad surprises.
In these days it happened to me to work on a couple of custom Plone edit forms using ajax calls to simplify user data entry.
At a first glance, the user experience was great, but under the hood the whole machinery was hiding potential problems, the reason being that in both cases the ajax calls used in the form were relative to the document path, even when if the document was in the factory!
This means that every time the ajax call was invoked, additional security checks were performed and in the case of the documents inside the factory other this lead to an unwanted creation of temporary documents!
The security checks and the portal factory abuse increased the response time and could potentially raise conflict errors.
During the development phase the problem is hardly noticeable, but on a production server it will probably make the form unusable, especially if you complex security checks are needed.
The solution was simply to call the views with another context (in those cases the container).
Lesson learned: be careful to the context of your ajax call