Using ElementTree as backend for a chat web application issues

Marcelo de Moraes Serpa celoserpa at gmail.com
Mon Jun 9 20:32:00 CEST 2008


Hello list,

I've built a chat with a front-end Ajax client and backend usign ElementTree
to persist the data.

The problem is that the xml structure I use to persist some of the global
configuration of the application usually gets corrupted, for example, let's
say the structure is something like:

<backend>
 <chat_list>
   <chat .../>
   <chat .../>
  </chat_list>
</backend>

In some circunstances I could not yet discover (it seems random) when I
edit/save the structure, the structure gets corrupted, elementree seems to
get lost in its internal "cursor", usually something like this happens:

<backend>
 <chat_list>
   <chat id="1">
   <chat id="2">
  </chat_list>
</backend>id="3"/></backend>

Pretty strange, and it drives the whole application unusable.

I don't know if the concurrent nature of the application (multiple users
using the client at almost the same time and sending data to the server
which in turn must save the data to the same global.xml file) has something
to do with it - I don't know if ElementTree is suitable for this kind of
thing. How to hanlde this concurrent issue?

My code seems to work ok, as when the XML doesn't get corrupted, all the
features of the chat work nicely.

I can show the code here, but it is too big and I don't have a clue where
this problem would be sitted. It is simple, it just uses the parse method of
elementree to read the xml and the write method to write, nothing fancy.

If someone could "smell" what could be the cause of this problem and tell
me, I would be grateful.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080609/2afd0388/attachment.html>


More information about the Python-list mailing list