Opened 15 years ago

Closed 13 years ago

Last modified 13 years ago

#11474 closed (duplicate)

models.XMLField doesn't work as advertised

Reported by: Jim Garrison Owned by: nobody
Component: Documentation Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

There are two errors currently in the (documentation of) models.XMLField:

  • The documentation claims that schema_path is a required argument, but it is not.
  • Regardless of whether schema_path is given, models.XMLField does not actually perform any validation. It works no differently than an ordinary TextField, succeeding even if the input is not XML at all.

Tickets #3094 and #5620 are likely related to this bug. I reference them for historical interest, since it seems that it was once assumed that #3094 would to be fixed before 1.0.

Change History (5)

comment:1 by Alex Gaynor, 15 years ago

Triage Stage: UnreviewedAccepted

comment:2 by django@…, 14 years ago

As a stopgap measure, xml.parsers.expat could be used to verify that the XML is at least well-formed, albeit perhaps not compliant with any particular schema.

For example, I currently use the following on a form that allows users to input XML in a multi-line text field:

    def clean_dialplan_xml(self):
        from xml.parsers import expat
        tmp = expat.ParserCreate()

        try:
            tmp.Parse(self.cleaned_data['dialplan_xml'])
        except expat.ExpatError, e:
            raise forms.ValidationError(e)

        return self.cleaned_data['dialplan_xml']

This could/should perhaps be instead implemented in django.db.models.fields instead.

comment:3 by Paul McMillan, 13 years ago

Component: Database layer (models, ORM)Documentation
milestone: 1.3

This is really a docs ticket. I'm changing the category to reflect that, so that it'll get some attention.

#3094 will be resolved whenever it gets resolved (if ever) but in the meantime the docs should reflect the way Django really functions (especially for 1.1 and 1.2 where the feature will never surface).

I suggest changing the relevant docs to read something like:

A TextField for XML. Does not currently provide any validation. Takes one optional argument:

schema_path
The filesystem path to an XML schema.

In addition to posting here, I'll try and get that ticket moving as well.

comment:4 by Gabriel Hurley, 13 years ago

Resolution: duplicate
Status: newclosed

Closing as a duplicate of #3094. There's no point in changing the docs until that ticket is resolved. My thoughts on what the resolution should be are noted on that ticket.

comment:5 by Jacob, 13 years ago

milestone: 1.3

Milestone 1.3 deleted

Note: See TracTickets for help on using tickets.
Back to Top