Hey,
  this is more of a python question than a django question. I have an
XML parser set up to read some files and I want to create a list of
dictionaries to pass to the method in the view. When i create the
list, all the dictionary items end up being the same, instead of
unique like they should be. The following is my endelement code for
the content handler and i will include the code from the actual parser
after that, thanks for any help that comes my way.

def endElement(self, name):
        if name == 'vidars_search_result':
            return
        elif name == 'match':
            self.datasets.append(self.single)
        elif name == 'udi':
            self.single['udi'] = self.udiStr
            self.udi = 0
        elif name == 'url':
            self.single['url'] = self.urlStr
            self.url = 0
        elif name == 'start_date':
            self.single['start_date'] = self.start_dateStr
            self.start_date = 0
        elif name == 'end_date':
            self.single['end_date'] = self.end_dateStr
            self.end_date = 0
        elif name == 'data_set_type':
            self.single['data_set_type'] = self.data_set_typeStr
            self.data_set_type = 0
        elif name == 'start_time':
            self.single['start_time'] = self.start_timeStr
            self.start_time = 0
        elif name == 'end_time':
            self.single['end_time'] = self.end_timeStr
            self.end_time = 0
        elif name == 'metadata':
            self.single['metadata'] = self.metadataStr
            self.metadata = 0


here is the parser:

from xmlContent import GetSet
from xml.sax import make_parser
from xml.sax.handler import feature_namespaces

class XMLParser:

    def __init__(self):
        self.datasets = []

    def getDatasets(self):
        return self.datasets

    def execute_parser(self, file):
        f = open(file)
        parser = make_parser()

        parser.setFeature(feature_namespaces, 0)
        handler = GetSet()
        parser.setContentHandler(handler)
        parser.parse(f)

        self.datasets = handler.get_datasetList()
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to