changeset 117:eb46d3641b93

arnica_slides: checks required parameters for slide_show
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Fri, 27 Jun 2008 10:38:10 +0200
parents 4891dc042095
children 267d1b2c2337
files data/plugin/action/arnica_slides.py
diffstat 1 files changed, 18 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/action/arnica_slides.py	Fri Jun 27 09:49:14 2008 +0200
+++ b/data/plugin/action/arnica_slides.py	Fri Jun 27 10:38:10 2008 +0200
@@ -352,29 +352,41 @@
         _ = self.request.getText
         request = self.request
         if not request.user.may.read(pagename):
-            msg = _("You are not allowed to view this page.")
+            msg = _("You are not allowed to view this page!")
             request.theme.add_msg(msg, "error")
             Page(request, pagename).send_page()
+            return
 
         target = request.form.get('target', [''])[0]
         images = request.form.get('images', [''])[0]
+        all_description = request.form.get('alias', [''])[0]
+        all_exif_date = request.form.get('exif_date', [''])[0]
+        image_for_webnail = (request.form.get("image_for_webnail", [0])[0])  == u'True'
+
+        if not (target and images and all_description and all_exif_date):
+            msg = _("Missing required parameters!")
+            request.theme.add_msg(msg, "error")
+            Page(request, pagename).send_page()
+            return
 
         images = unpackLine(images)
         images = (images[1:])
 
-        all_description = request.form.get('alias', [''])[0]
         all_description = unpackLine(all_description)
-        #this_description = all_description[0]
         all_description = (all_description[1:])
 
-        all_exif_date = request.form.get('exif_date', [''])[0]
         all_exif_date = unpackLine(all_exif_date)
         all_exif_date = (all_exif_date[1:])
 
         # XXX Check that all lists have same length
-        idx = images.index(target)
+        try:
+            idx = images.index(target)
+        except ValueError:
+            msg =  _("Attachment '%(filename)s' does not exist!") % {'filename': target}
+            request.theme.add_msg(msg, "error")
+            Page(request, pagename).send_page()
+            return
 
-        image_for_webnail = (request.form.get("image_for_webnail", [0])[0])  == u'True'
         web = {}
         if not image_for_webnail:
             web['src'] = getAttachUrl(request.getScriptname(), pagename, target)