1.1 --- a/examples/Common/Questionnaire/Resources/question_template.xhtml Sat Jun 20 00:26:12 2009 +0200
1.2 +++ b/examples/Common/Questionnaire/Resources/question_template.xhtml Mon Jun 22 21:45:16 2009 +0200
1.3 @@ -20,6 +20,8 @@
1.4 <input type="submit" value="Import" name="import" />
1.5 </p>
1.6
1.7 +<p class="error" template:if="@error">The file could not be loaded.</p>
1.8 +
1.9 <div class="questionnaire">
1.10
1.11 <p>Or enter questions and possible responses below.</p>
2.1 --- a/examples/Common/Questionnaire/__init__.py Sat Jun 20 00:26:12 2009 +0200
2.2 +++ b/examples/Common/Questionnaire/__init__.py Mon Jun 22 21:45:16 2009 +0200
2.3 @@ -86,11 +86,16 @@
2.4
2.5 if parameters.has_key("import"):
2.6 importfile = parameters["importfile"][0]
2.7 - try:
2.8 - doc = libxml2dom.parse(importfile.stream)
2.9 - form.set_document(doc)
2.10 - except libxml2dom.LSException:
2.11 - pass
2.12 +
2.13 + if hasattr(importfile, "stream"):
2.14 + try:
2.15 + doc = libxml2dom.parse(importfile.stream)
2.16 + form.set_document(doc)
2.17 + return # success
2.18 + except libxml2dom.LSException:
2.19 + pass
2.20 +
2.21 + questionnaire.documentElement.setAttribute("error", "true")
2.22
2.23 def init_document(self, trans, form):
2.24