Index: /WAeUP_SRP/base/WAeUPTool.py
===================================================================
--- /WAeUP_SRP/base/WAeUPTool.py	(revision 2334)
+++ /WAeUP_SRP/base/WAeUPTool.py	(revision 2335)
@@ -693,7 +693,13 @@
     def showFsPicture(self,path):
         """return a picture from the filesystem"""
-        picture_path = "%s/import/%s" % (i_home,path)
+        picture_path = os.path.join(i_home,path)
+        response = self.REQUEST.RESPONSE
+        if os.path.exists(picture_path):
+            response.setHeader('Content-type','image/jpeg')
+            return open(picture_path).read()
+        picture_path = os.path.join(i_home,'import',path)
         if os.path.exists(picture_path):
             return open(picture_path).read()
+        
 
     ###)
Index: /WAeUP_SRP/base/Widgets.py
===================================================================
--- /WAeUP_SRP/base/Widgets.py	(revision 2334)
+++ /WAeUP_SRP/base/Widgets.py	(revision 2335)
@@ -1740,4 +1740,255 @@
 ###)
 
+class FileImageWidget(CPSImageWidget): ###(
+    """Image widget with filesystem storage."""
+    meta_type = 'File Image Widget'
+    _properties = CPSImageWidget._properties +\
+    (
+     {'id': 'path', 'type': 'string', 'mode': 'w',
+      'label': 'Relative Path'},
+     {'id': 'id_field', 'type': 'string', 'mode': 'w',
+      'label': 'Field to build the id'},
+    )
+    path = "images"
+    storage_path = "%s/%s" % (i_home,path)
+    id_field = ""
+
+    def getImageInfo(self, datastructure): ###(
+        """Get the file info from the datastructure."""
+        #import pdb; pdb.set_trace()
+        widget_id = self.getWidgetId()
+        if  datastructure.has_key(widget_id):
+            fileupload = datastructure[widget_id]
+            dm = datastructure.getDataModel()
+            field_id = self.fields[0]
+            if self.id_field == "":
+                student_id = self.getStudentId()
+            else:
+                student_id = datastructure[self.id_field]
+            content_url = os.path.join(self.portal_url(),
+                                       "viewimage",
+                                       self.path,
+                                       student_id,
+                                       "%s_%s.jpg" % (self.getWidgetId(),student_id),
+                                       )
+            image_title = "%s_%s.jpg" % (widget_id,student_id)
+            current_filename = os.path.join(student_id,
+                                            image_title)
+            file_path = os.path.join(self.storage_path,
+                                     current_filename)
+        else:
+            file_path = "XXX"
+            image_title = ""
+        # read the file from the filesystem
+        if not os.path.exists(file_path):
+            height = -1
+            width = -1
+            empty_file = True
+            session_file = False
+            current_filename = ''
+            content_url = ''
+            size = 0
+            mimetype = ''
+            last_modified = ''
+            height = ''
+            width = ''
+        else:
+            image = open(file_path)
+            from OFS.Image import getImageInfo as getImageInfoOFS
+            image.seek(0)
+            data = image.read(2000)
+            size = len(data)
+            empty_file = size == 0
+            session_file = False
+            last_modified = ''
+            image.close()
+            mimetype, width, height = getImageInfoOFS(data)
+            registry = getToolByName(self, 'mimetypes_registry')
+            mimetype = (registry.lookupExtension(current_filename.lower()) or
+                        registry.lookupExtension('file.bin'))
+            if width < 0:
+                width = None
+            if height < 0:
+                height = None
+
+            if (self.allow_resize
+                and height is not None
+                and width  is not None):
+                z_w = z_h = 1
+                h = int(self.display_height)
+                w = int(self.display_width)
+                if w and h:
+                    if w < width:
+                        z_w = w / float(width)
+                    if h < height:
+                        z_h = h / float(height)
+                    zoom = min(z_w, z_h)
+                    width = int(zoom * width)
+                    height = int(zoom * height)
+                #import pdb;pdb.set_trace()
+        title = image_title
+        image_info = {
+            'empty_file': empty_file,
+            'session_file': session_file,
+            'current_filename': title,
+            'size': size,
+            'last_modified': last_modified,
+            'content_url': content_url,
+            'mimetype': mimetype,
+            }
+        alt = title or ''
+        #height = int(self.display_height)
+        #width = int(self.display_width)
+        if height is None or width is None:
+            tag = renderHtmlTag('img', src=image_info['content_url'],
+                                alt=alt, title=title)
+        else:
+            tag = renderHtmlTag('img', src=image_info['content_url'],
+                                width=str(width), height=str(height),
+                                alt=alt, title=title)
+
+        image_info['height'] = height
+        image_info['width'] = width
+        image_info['image_tag'] = tag
+        return image_info
+    ###)
+
+    def checkFileName(self, filename, mimetype):
+        return '', {}
+        if mimetype and mimetype.startswith('image'):
+            return '', {}
+        return 'cpsschemas_err_image', {}
+
+    def prepare(self, datastructure, **kw): ###(
+        """Prepare datastructure from datamodel."""
+        datamodel = datastructure.getDataModel()
+        widget_id = self.getWidgetId()
+        file_name = datamodel[self.fields[0]]
+        #import pdb; pdb.set_trace()
+        if self.allow_resize:
+            datastructure[self.getWidgetId() + '_resize'] = ''
+        datastructure[widget_id] = file_name
+        datastructure[widget_id + '_choice'] = 'change'
+        title = 'Passport Foto'
+        datastructure[widget_id + '_filename'] = title
+    ###)
+
+    def validate(self, datastructure, **kw): ###(
+        """Update datamodel from user data in datastructure.
+        """
+        logger = logging.getLogger('Widgets.FileImageWidget.validate')
+        datamodel = datastructure.getDataModel()
+        field_id = self.fields[0]
+        widget_id = self.getWidgetId()
+        store = False
+        fileupload = None
+        mimetype = None
+        old_file = datamodel[field_id]
+        # if old_file is not None:
+        #     old_filename = old_file.title
+        # else:
+        #     old_filename = ''
+        choice = datastructure[widget_id+'_choice']
+        fileupload = datastructure[widget_id]
+        is_upload = isinstance(fileupload, FileUpload)
+        #import pdb; pdb.set_trace()
+        if not is_upload and not datamodel[field_id]:
+            if self.is_required:
+                return self.validateError('Picture upload required', {},
+                                          datastructure)
+        if self.id_field == "":
+            student_id = self.getStudentId()
+        else:
+            student_id = datastructure[self.id_field]
+        if choice == 'delete':
+            if self.is_required:
+                return self.validateError('cpsschemas_err_required', {},
+                                          datastructure)
+            ext ='jpg'
+            filename = "%s_%s.%s" % (self.getWidgetId(),
+                                     student_id,
+                                     ext)
+            # Remove the file in the filesystem
+            student_path = os.path.join(self.storage_path,student_id)
+            full_path = os.path.join(student_path, filename)
+            if os.path.exists(full_path):
+                os.remove(full_path)
+            datamodel[field_id] = None
+        elif choice == 'keep':
+            fileupload = datastructure[widget_id]
+            if isinstance(fileupload, PersistableFileUpload):
+                # Keeping something from the session means we
+                # actually want to store it.
+                store = True
+            # else:
+            #     # Nothing to change, don't pollute datastructure
+            #     # with something costly already stored, which therefore
+            #     # doesn't need to be kept in the session.
+            #     self.unprepare(datastructure)
+        elif choice == 'change' and is_upload:
+            if not fileupload:
+                return self.validateError('cpsschemas_err_file_empty', {},
+                                          datastructure)
+            if not isinstance(fileupload, FileUpload):
+                return self.validateError('cpsschemas_err_file', {},
+                                          datastructure)
+            fileupload.seek(0, 2) # end of file
+            size = fileupload.tell()
+            if not size:
+                return self.validateError('cpsschemas_err_file_empty', {},
+                                          datastructure)
+            if self.size_max and size > self.size_max:
+                max_size_str = self.getHumanReadableSize(self.size_max)
+                err = 'This file is too big, the allowed max size is ${max_size}'
+                logger.info('%s tried to upload picture with size %dk' %(datastructure['reg_no'],int(size)/1000) )
+                err_mapping = {'max_size': max_size_str}
+                return self.validateError(err, err_mapping, datastructure)
+            store = True
+
+
+        # Find filename
+        if is_upload and store:
+            ext ='jpg'
+            filename = "%s_%s.%s" % (self.getWidgetId(),
+                                     student_id,
+                                     ext)
+            datamodel[field_id] = filename
+            registry = getToolByName(self, 'mimetypes_registry')
+            mimetype = registry.lookupExtension(filename.lower())
+            if mimetype is not None:
+                mimetype = str(mimetype) # normalize
+            #import pdb; pdb.set_trace()
+            file = self.makeFile(filename, fileupload, datastructure)
+            # Fixup mimetype
+            if mimetype and file.content_type != mimetype:
+                file.content_type = mimetype
+            # Store the file in the filesystem
+            student_path = os.path.join(self.storage_path,student_id)
+            if not os.path.exists(student_path):
+                os.mkdir(student_path)
+            full_path = os.path.join(student_path, filename)
+            #import pdb;pdb.set_trace()
+            pict = open(full_path,"w")
+            fileupload.seek(0)
+            pict.write(fileupload.read())
+            pict.close()
+        return True
+
+###)
+
+    def render(self, mode, datastructure, **kw): ###(
+        render_method = 'widget_image_render'
+        meth = getattr(self, render_method, None)
+        if meth is None:
+            raise RuntimeError("Unknown Render Method %s for widget type %s"
+                               % (render_method, self.getId()))
+        img_info = self.getImageInfo(datastructure)
+        return meth(mode=mode, datastructure=datastructure, **img_info)
+    ###)
+
+InitializeClass(FileImageWidget)
+
+widgetRegistry.register(FileImageWidget)
+###)
 
 ###########
Index: /WAeUP_SRP/base/skins/waeup_student/getApplicationInfo.py
===================================================================
--- /WAeUP_SRP/base/skins/waeup_student/getApplicationInfo.py	(revision 2334)
+++ /WAeUP_SRP/base/skins/waeup_student/getApplicationInfo.py	(revision 2335)
@@ -12,6 +12,4 @@
 return Info about the current Student
 """
-import logging
-logger = logging.getLogger('Skins.getApplicationInfo')
 
 request = context.REQUEST
@@ -28,4 +26,6 @@
 requested_id = context.getStudentId()
 if requested_id and not context.isStaff() and member_id != requested_id:
+    import logging
+    logger = logging.getLogger('Skins.getApplicationInfo')
     logger.info('%s tried to access application object of %s' % (member_id,requested_id))
     student_id = requested_id
Index: /WAeUP_SRP/base/skins/waeup_utilities/viewimage.py
===================================================================
--- /WAeUP_SRP/base/skins/waeup_utilities/viewimage.py	(revision 2334)
+++ /WAeUP_SRP/base/skins/waeup_utilities/viewimage.py	(revision 2335)
@@ -5,5 +5,5 @@
 ##bind script=script
 ##bind subpath=traverse_subpath
-##parameters=path
+##parameters=path=None
 ##title=
 ##
@@ -16,4 +16,6 @@
     def set_trace():
         pass
+if path is None and traverse_subpath:
+    path = "/".join(traverse_subpath)
 return context.waeup_tool.showFsPicture(path)
 #import logging
Index: /WAeUP_SRP/uniben/profiles/default/layouts/student_clearance.xml
===================================================================
--- /WAeUP_SRP/uniben/profiles/default/layouts/student_clearance.xml	(revision 2334)
+++ /WAeUP_SRP/uniben/profiles/default/layouts/student_clearance.xml	(revision 2335)
@@ -8,5 +8,5 @@
  <property name="flexible_widgets"/>
  <property name="validate_values_expr"></property>
- <widget name="acc_inst" meta_type="Image Widget">
+ <widget name="acc_inst" meta_type="File Image Widget">
   <property name="title">Accepted by Institution</property>
   <property name="fields">
@@ -25,5 +25,5 @@
   <property name="allow_resize">True</property>
  </widget>
- <widget name="acc_let" meta_type="Image Widget">
+ <widget name="acc_let" meta_type="File Image Widget">
   <property name="title">Acceptance Letter </property>
   <property name="fields">
@@ -42,5 +42,5 @@
   <property name="allow_resize">True</property>
  </widget>
- <widget name="age_dec" meta_type="Image Widget">
+ <widget name="age_dec" meta_type="File Image Widget">
   <property name="title">Age Declaration</property>
   <property name="fields">
@@ -115,5 +115,5 @@
   <property name="hidden_readonly_layout_modes"/>
  </widget>
- <widget name="alr_scan" meta_type="Image Widget">
+ <widget name="alr_scan" meta_type="File Image Widget">
   <property name="title">Scan of Advanced Level Result</property>
   <property name="fields">
@@ -132,5 +132,5 @@
   <property name="allow_resize">True</property>
  </widget>
- <widget name="birth_certificate" meta_type="Image Widget">
+ <widget name="birth_certificate" meta_type="File Image Widget">
   <property name="title">Birth Certificate</property>
   <property name="fields">
@@ -165,5 +165,5 @@
   <property name="time_setting">False</property>
  </widget>
- <widget name="cert" meta_type="Image Widget">
+ <widget name="cert" meta_type="File Image Widget">
   <property name="title">Certificate</property>
   <property name="fields">
@@ -196,5 +196,5 @@
   <property name="prefix">CLR</property>
  </widget>
- <widget name="cred" meta_type="Image Widget">
+ <widget name="cred" meta_type="File Image Widget">
   <property name="title">Credential</property>
   <property name="fields">
@@ -280,5 +280,5 @@
   <property name="time_setting">False</property>
  </widget>
- <widget name="evid" meta_type="Image Widget">
+ <widget name="evid" meta_type="File Image Widget">
   <property name="title">Evidence of Name</property>
   <property name="fields">
@@ -369,5 +369,5 @@
   <property name="hidden_readonly_layout_modes"/>
  </widget>
- <widget name="fst_sit_scan" meta_type="Image Widget">
+ <widget name="fst_sit_scan" meta_type="File Image Widget">
   <property name="title">Scan of First Sitting Result</property>
   <property name="fields">
@@ -440,5 +440,5 @@
   <property name="hidden_readonly_layout_modes"/>
  </widget>
- <widget name="hq_scan" meta_type="Image Widget">
+ <widget name="hq_scan" meta_type="File Image Widget">
   <property name="title">Scan of Higher Qualification Result</property>
   <property name="fields">
@@ -498,5 +498,5 @@
   <property name="vocabulary">high_qual</property>
  </widget>
- <widget name="jamb_let" meta_type="Image Widget">
+ <widget name="jamb_let" meta_type="File Image Widget">
   <property name="title">JAMB Letter</property>
   <property name="fields">
@@ -515,5 +515,5 @@
   <property name="allow_resize">True</property>
  </widget>
- <widget name="jamb_slip" meta_type="Image Widget">
+ <widget name="jamb_slip" meta_type="File Image Widget">
   <property name="title">JAMB Slip</property>
   <property name="fields">
@@ -546,5 +546,5 @@
   <property name="vocabulary">local_gov_areas</property>
  </widget>
- <widget name="lga_ident" meta_type="Image Widget">
+ <widget name="lga_ident" meta_type="File Image Widget">
   <property name="title">LGA Identification</property>
   <property name="fields">
@@ -593,5 +593,5 @@
   <property name="vocabulary">states</property>
  </widget>
- <widget name="ref_let" meta_type="Image Widget">
+ <widget name="ref_let" meta_type="File Image Widget">
   <property name="title">Referee Letter</property>
   <property name="fields">
@@ -610,5 +610,5 @@
   <property name="allow_resize">True</property>
  </widget>
- <widget name="res_stat" meta_type="Image Widget">
+ <widget name="res_stat" meta_type="File Image Widget">
   <property name="title">Result Statement</property>
   <property name="fields">
@@ -684,5 +684,5 @@
   <property name="hidden_readonly_layout_modes"/>
  </widget>
- <widget name="scd_sit_scan" meta_type="Image Widget">
+ <widget name="scd_sit_scan" meta_type="File Image Widget">
   <property name="title">Scan of Second Sitting Result</property>
   <property name="fields">
@@ -715,5 +715,5 @@
   <property name="vocabulary">exam_types</property>
  </widget>
- <widget name="stat_dec" meta_type="Image Widget">
+ <widget name="stat_dec" meta_type="File Image Widget">
   <property name="title">Statutory Declaration of Good Conduct</property>
   <property name="fields">
Index: /WAeUP_SRP/uniben/profiles/default/layouts/student_clearance_fe.xml
===================================================================
--- /WAeUP_SRP/uniben/profiles/default/layouts/student_clearance_fe.xml	(revision 2334)
+++ /WAeUP_SRP/uniben/profiles/default/layouts/student_clearance_fe.xml	(revision 2335)
@@ -8,5 +8,5 @@
  <property name="flexible_widgets"/>
  <property name="validate_values_expr"></property>
- <widget name="acc_inst" meta_type="Image Widget">
+ <widget name="acc_inst" meta_type="File Image Widget">
   <property name="title">Accepted by Institution</property>
   <property name="fields">
@@ -25,5 +25,5 @@
   <property name="allow_resize">True</property>
  </widget>
- <widget name="acc_let" meta_type="Image Widget">
+ <widget name="acc_let" meta_type="File Image Widget">
   <property name="title">Acceptance Letter </property>
   <property name="fields">
@@ -42,5 +42,5 @@
   <property name="allow_resize">True</property>
  </widget>
- <widget name="age_dec" meta_type="Image Widget">
+ <widget name="age_dec" meta_type="File Image Widget">
   <property name="title">Age Declaration</property>
   <property name="fields">
@@ -116,5 +116,5 @@
   <property name="hidden_readonly_layout_modes"/>
  </widget>
- <widget name="alr_scan" meta_type="Image Widget">
+ <widget name="alr_scan" meta_type="File Image Widget">
   <property name="title">Scan of Advanced Level Result</property>
   <property name="fields">
@@ -133,5 +133,5 @@
   <property name="allow_resize">True</property>
  </widget>
- <widget name="birth_certificate" meta_type="Image Widget">
+ <widget name="birth_certificate" meta_type="File Image Widget">
   <property name="title">Birth Certificate</property>
   <property name="fields">
@@ -166,5 +166,5 @@
   <property name="time_setting">False</property>
  </widget>
- <widget name="cert" meta_type="Image Widget">
+ <widget name="cert" meta_type="File Image Widget">
   <property name="title">Certificate</property>
   <property name="fields">
@@ -197,5 +197,5 @@
   <property name="prefix">CLR</property>
  </widget>
- <widget name="cred" meta_type="Image Widget">
+ <widget name="cred" meta_type="File Image Widget">
   <property name="title">Credential</property>
   <property name="fields">
@@ -281,5 +281,5 @@
   <property name="time_setting">False</property>
  </widget>
- <widget name="evid" meta_type="Image Widget">
+ <widget name="evid" meta_type="File Image Widget">
   <property name="title">Evidence of Name</property>
   <property name="fields">
@@ -355,5 +355,5 @@
   <property name="hidden_readonly_layout_modes"/>
  </widget>
- <widget name="fst_sit_scan" meta_type="Image Widget">
+ <widget name="fst_sit_scan" meta_type="File Image Widget">
   <property name="title">Scan of First Sitting Result</property>
   <property name="fields">
@@ -426,5 +426,5 @@
   <property name="hidden_readonly_layout_modes"/>
  </widget>
- <widget name="hq_scan" meta_type="Image Widget">
+ <widget name="hq_scan" meta_type="File Image Widget">
   <property name="title">Scan of Higher Qualification Result</property>
   <property name="fields">
@@ -484,5 +484,5 @@
   <property name="vocabulary">high_qual</property>
  </widget>
- <widget name="jamb_let" meta_type="Image Widget">
+ <widget name="jamb_let" meta_type="File Image Widget">
   <property name="title">JAMB Letter</property>
   <property name="fields">
@@ -501,5 +501,5 @@
   <property name="allow_resize">True</property>
  </widget>
- <widget name="jamb_slip" meta_type="Image Widget">
+ <widget name="jamb_slip" meta_type="File Image Widget">
   <property name="title">JAMB Slip</property>
   <property name="fields">
@@ -533,5 +533,5 @@
   <property name="vocabulary">local_gov_areas</property>
  </widget>
- <widget name="lga_ident" meta_type="Image Widget">
+ <widget name="lga_ident" meta_type="File Image Widget">
   <property name="title">LGA Identification</property>
   <property name="fields">
@@ -599,5 +599,5 @@
   <property name="vocabulary">states</property>
  </widget>
- <widget name="ref_let" meta_type="Image Widget">
+ <widget name="ref_let" meta_type="File Image Widget">
   <property name="title">Referee Letter</property>
   <property name="fields">
@@ -616,5 +616,5 @@
   <property name="allow_resize">True</property>
  </widget>
- <widget name="res_stat" meta_type="Image Widget">
+ <widget name="res_stat" meta_type="File Image Widget">
   <property name="title">Result Statement</property>
   <property name="fields">
@@ -690,5 +690,5 @@
   <property name="hidden_readonly_layout_modes"/>
  </widget>
- <widget name="scd_sit_scan" meta_type="Image Widget">
+ <widget name="scd_sit_scan" meta_type="File Image Widget">
   <property name="title">Scan of Second Sitting Result</property>
   <property name="fields">
@@ -721,5 +721,5 @@
   <property name="vocabulary">exam_types</property>
  </widget>
- <widget name="stat_dec" meta_type="Image Widget">
+ <widget name="stat_dec" meta_type="File Image Widget">
   <property name="title">Statutory Declaration of Good Conduct</property>
   <property name="fields">
