Django

40 views
Skip to first unread message

Victor Hooi

unread,
Dec 1, 2011, 7:39:27 PM12/1/11
to django...@googlegroups.com
Hi,

I'm writing a  Django application to mange some XML configuration files through the Django-admin.

Currently, I'm converting the XML values/hierarchies into Django models.

After this, we also need to code an import - to import in configuration files and populate Django models based on them, and also an export, to export from our Django models back into the finished XML configuration files.

However, another way might be just to inspect the XSD files we have, and try to create the models from that.

I know there's django-models-schemas (https://bitbucket.org/eegg/django-model-schemas/wiki/Home), that is meant to generate XSD files from Django models. I'm not aware of anything going the other way (introspecting XSD files to get Django models).

However, what are your thoughts on this?

Is there an easier way of achieving the main goal - editing XMl configuration files through a Django interface? Things I should be aware of?

Cheers,
Victor

Victor Hooi

unread,
Dec 1, 2011, 7:40:22 PM12/1/11
to django...@googlegroups.com
heya,

Damn, I didn't edit the subject - apologies - if there's a moderator, can you change it to "Using Django to edit XML configuration files" please?

Thanks,
Victor

Reinout van Rees

unread,
Dec 2, 2011, 4:07:51 AM12/2/11
to django...@googlegroups.com
On 02-12-11 01:39, Victor Hooi wrote:
> Is there an easier way of achieving the main goal - editing XMl
> configuration files through a Django interface? Things I should be aware of?
>

Depends a LOT on the kind of XML files. Are they the document kind,
mixed content all around? Like a HTML file? Or are they the structured
kind with a fixed structure?

Your main problem will probably be mapping the xml structure to a
relational model.

Some brainstorming:

- Look at a nosql backend for Django: a nosql database might store xml
in a more xml-friendly way.

- First convert the xml to json? Might be easier to store?

- Convert the .xsd schema to .rng or something like that: more readable.
And, importantly, easier parseable by a python script: you could write
your own models.py generator this way :-)

- Do you want to store it in separate models or in one big chunk of
xml/json? Depends on how you want to edit.

Reinout

--
Reinout van Rees http://reinout.vanrees.org/
rei...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

Victor Hooi

unread,
Dec 2, 2011, 5:10:37 AM12/2/11
to django...@googlegroups.com
Hi,

The XML files are all configuration files, storing things like boolean configuration flags, timeout values, username/passwords, IP addresses and ports etc.

Some of them will maps somewhat logically to the relational model - for example, they'll be a configuration for an application, as well as each of it's sub-modules, as well as usernames/passwords linked to the application etc.

I've included three example XSD files - hopefully that will give you a better idea.

The reason we're using Django is I was hoping to leverage off the Django-admin, as well as Django forms, if need be, to provide an easy interface to edit the files, and enforce some validation rules (many of which aren't really contained in the XML/XSD files).

And the other issue is the configuration format may change over time, so we'll need to keep the models.py up-to-date, not sure of the best way to do that.

Cheers,
Victor
CConfigRefData.xsd
CConfigFIXAA.xsd
CConfigXXX.xsd
Reply all
Reply to author
Forward
0 new messages