Index: /main/waeup.sirp/trunk/src/waeup/sirp/applicants/applicant.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/applicants/applicant.py	(revision 7120)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/applicants/applicant.py	(revision 7121)
@@ -201,10 +201,19 @@
         """
         marker, filename, basename, ext = store.extractMarker(file_id)
-        return os.path.join(root, 'applicants', filename)
+        sub_root = os.path.join(root, 'applicants')
+        return super(ApplicantImageStoreHandler, self).pathFromFileID(
+            store, sub_root, basename)
 
     def createFile(self, store, root, filename, file_id, file):
         """Create a browsable file-like object.
         """
-        # possible other actions: check for jpeg format
-        path = self.pathFromFileID(store, root, file_id)
-        return file, path, WAeUPImageFile(filename, file_id)
+        ext = os.path.splitext(filename)[1].lower()
+        if ext not in ['.jpg', '.png']:
+            raise ValueError('Only .jpg and .png allowed')
+        # call super method to ensure that any old files with
+        # different filename extension are deleted.
+        file, path, file_obj =  super(
+            ApplicantImageStoreHandler, self).createFile(
+            store, root,  filename, file_id, file)
+        return file, path, WAeUPImageFile(
+            file_obj.filename, file_obj.data)
Index: /main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_applicant.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_applicant.py	(revision 7120)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_applicant.py	(revision 7121)
@@ -23,5 +23,9 @@
 """
 import grok
+import os
+import shutil
+import tempfile
 import unittest
+from StringIO import StringIO
 from zope.component import adapts, queryUtility
 from zope.component.interfaces import IFactory
@@ -48,4 +52,14 @@
     layer = FunctionalLayer
 
+    def setUp(self):
+        super(HelperTests, self).setUp()
+        self.workdir = tempfile.mkdtemp()
+        return
+
+    def tearDown(self):
+        super(HelperTests, self).tearDown()
+        shutil.rmtree(self.workdir)
+        return
+
     def test_get_regno_or_ac(self):
         # we can get reg_no or access_code of an applicants if it is set
@@ -85,9 +99,31 @@
             store, '/fake-root', '__img-applicant__dir1/dir2/sample.jpg')
         self.assertEqual(
-            result1, '/fake-root/applicants/sample.jpg')
-        self.assertEqual(
-            result2, '/fake-root/applicants/dir1/sample.jpg')
-        self.assertEqual(
-            result3, '/fake-root/applicants/dir1/dir2/sample.jpg')
+            result1, '/fake-root/applicants/sample')
+        self.assertEqual(
+            result2, '/fake-root/applicants/dir1/sample')
+        self.assertEqual(
+            result3, '/fake-root/applicants/dir1/dir2/sample')
+        return
+
+    def test_image_store_handler_create(self):
+        # we can create files in image store with the applicant image
+        # store handler
+        store = DefaultStorage(self.workdir)
+        handler = queryUtility(IFileStoreHandler, name='img-applicant')
+        file_obj, path, waeup_file = handler.createFile(
+            store, store.root, 'sample.jpg', '__img_applicant__sample',
+            StringIO('I am a JPG file'))
+        self.assertEqual(path[-21:], 'applicants/sample.jpg')
+        return
+
+    def test_image_store_handler_invalid_filename_ext(self):
+        # we only accept '.jpg' and '.png' as filename extensions.
+        store = DefaultStorage()
+        handler = queryUtility(IFileStoreHandler, name='img-applicant')
+        self.assertRaises(
+            ValueError,
+            handler.createFile,
+            store, store.root, 'sample.txt', '__img_applicant__sample',
+            StringIO('I am a txt file'))
         return
 
