[Products.SilvaExternalSources][Emiliano D'Alterio] Fixed "Unbou...

[email protected] Tue, 10 Sep 2013 14:41:06 +0200
Newsgroups gmane.comp.web.zope.silva.cvs
Message-ID <[email protected]>
author:    Emiliano D'Alterio
date:      Tue Sep 10 14:39:45 2013 +0200
revision:  1111:ab9668c78e28 in Products.SilvaExternalSources
branch:    2.4
details:   https://hg.infrae.com/Products.SilvaExternalSources?cmd=changeset;node=ab9668c78e28
modified:  Products/SilvaExternalSources/editor/rest.py
added:     
removed:   
log:       Fixed "UnboundLocalError" upon receiving a
	Products.SilvaExternalSources.source.parameters POST request in some
	particular condititions.


diffstat:

 Products/SilvaExternalSources/editor/rest.py |  15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diffs (44 lines):

diff -r 9fece0dc4f26 -r ab9668c78e28 Products/SilvaExternalSources/editor/rest.py
--- a/Products/SilvaExternalSources/editor/rest.py	Fri Aug 30 19:26:53 2013 +0200
+++ b/Products/SilvaExternalSources/editor/rest.py	Tue Sep 10 14:39:45 2013 +0200
@@ -112,7 +112,8 @@
         try:
             source = self.get_source()
         except SourceError:
-            pass
+            self.request.response.setStatus(500)
+            return ''
         else:
             # Apply formulator styles. No choice here.
             for field in source.fields:
@@ -121,7 +122,7 @@
                         field.customize(STYLES[field.meta_type])
 
             for widget in source.fieldWidgets(
-                ignoreRequest=False, ignoreContent=False):
+                    ignoreRequest=False, ignoreContent=False):
                 label_class = ['cke_dialog_ui_labeled_label']
                 if widget.required:
                     label_class.append('cke_required')
@@ -131,7 +132,7 @@
                      'title': widget.title,
                      'description': widget.description,
                      'widget': widget.render()})
-        return self.json_response({
+            return self.json_response({
                 'title': source.label,
                 'parameters': self.template.render(self)})
 
@@ -148,9 +149,7 @@
             if errors:
                 return self.json_response(
                     {'success': False,
-                     'messages': [
-                            {'identifier': error.identifier,
-                             'message': error.title}
-                            for error in errors]})
+                     'messages': [{'identifier': error.identifier,
+                                   'message': error.title}
+                                  for error in errors]})
         return self.json_response({'success': True})
-