On Tue, 2007-06-05 at 06:05 -0700, jj wrote:
> I have added a feature to my Django app which allows me to import data
> from an external database. The data is in XML. I iterate over the XML
> to import book descriptions. After each book is processed, I save()
> it. Then I call render_response() to display the list of books just
> imported.
>
> However, the list has holes, i.e. not all fields are displayed. If I
> refresh the page, all book fields are now displayed. So they were
> there previously and some background process has now completed.
>
> # view
> def import_xml(request):
> if request.method == 'POST':
> post_data = request.POST.copy()
> post_data.update(request.FILES)
> form = forms.XmlUploadForm(post_data)
> if form.is_valid():
> list, log = form.save()
> return render_to_response('book_list.html', {'log': log,
> 'list': list})
> form = forms.XmlUploadForm()
> return home_page(request, form)
>
> # form.save()
> def save(self):
> xmldata = self.clean_data['xml_file']['content']
> xml = ElementTree.fromstring(xmldata)
> return do_import_xml(xml)
Everything you are doing here is single-threaded and it doesn't even
query the database, as far as I can see. However, you should look
closeley at the do_import_xml() function, since that is the invisible
part of the code samples you have posted.
Try checking the return values from the save() method very carefully to
see that they match what you expect.
Regards,
Malcolm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---