In fact, I always asked myself why there was a to_xml() instance method on an entity, without an from_xml() on the model class (the reverse method). If you have an answer, please, don't hesitate : tell me ;-)
So, I tried to make my own from_xml method. And it seems it works pretty good for me (afaik for the models of this website). So I want to share my work, so volunteers could help me to make it better : I take patches, and will maintain it.
My script exposes 2 methods :
exporte(*objects) : will generate (yield) a xml flow (using the to_xml()) of all "objects". object can be a Model class, in this case it will query all entities, or object can be some entities.
importe(objects,file=None,buffer=None,delete=False) : will import in models defined in objects, the xml flow from a file if file is defined, or from a buffer if buffer is defined. 'delete' will make a delete all before importing.