Index: /WAeUP_SRP/base/WAeUPTool.py
===================================================================
--- /WAeUP_SRP/base/WAeUPTool.py	(revision 2341)
+++ /WAeUP_SRP/base/WAeUPTool.py	(revision 2342)
@@ -695,4 +695,5 @@
         picture_path = os.path.join(i_home,path)
         response = self.REQUEST.RESPONSE
+        #import pdb;pdb.set_trace()
         if os.path.exists(picture_path):
             response.setHeader('Content-type','image/jpeg')
Index: /WAeUP_SRP/base/Widgets.py
===================================================================
--- /WAeUP_SRP/base/Widgets.py	(revision 2341)
+++ /WAeUP_SRP/base/Widgets.py	(revision 2342)
@@ -1335,4 +1335,35 @@
     reference = ''
 
+    def prepare(self, datastructure, **kw): ###(
+        """Prepare datastructure from datamodel."""
+        datamodel = datastructure.getDataModel()
+        v = datamodel[self.fields[0]]
+        widget_id = self.getWidgetId()
+        if v and type(v) is StringType:
+            try:
+                p,b,n = v.split('-')
+                v = ScratchCardPin(p,b,n)
+            except ValueError:
+                v = ScratchCardPin(v,'','')
+        if v:
+            p = '%s' % v.p
+            b = '%s' % v.b
+            n = '%s' % v.n
+        else:
+            p = self.prefix
+            if p.startswith('@'):
+                p = getattr(self,self.prefix[1:])()
+            b = n = ''
+            v = ScratchCardPin(p,b,n)
+        datastructure[widget_id] = v
+        datastructure[widget_id+'_p'] = p
+        datastructure[widget_id+'_b'] = b
+        datastructure[widget_id+'_n'] = n
+        screening_type = datamodel.get('screening_type',None)
+        if screening_type is None:
+            screening_type = self.REQUEST.form.get('screening_type','unknown')
+        datastructure["screening_type"] = screening_type
+    ###)
+
     def validate(self, datastructure, **kw): ###(
         """Validate datastructure and update datamodel."""
@@ -1396,5 +1427,6 @@
                 break
             if ok >= 1:
-                screening_type = self.REQUEST.form.get('screening_type','unknown')
+                #screening_type = self.REQUEST.form.get('screening_type','unknown')
+                screening_type = datastructure['screening_type']
                 if self.isStudent():
                     err = "This is only for Pume application."
@@ -1504,7 +1536,7 @@
 ###)
 
-class NoZodbImageWidget(CPSImageWidget): ###(
+class ApplicationImageWidget(CPSImageWidget): ###(
     """Image widget with filesystem storage."""
-    meta_type = 'No Zodb Image Widget'
+    meta_type = 'Application Image Widget'
     _properties = CPSImageWidget._properties +\
     (
@@ -1520,5 +1552,4 @@
     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):
@@ -1526,13 +1557,11 @@
             dm = datastructure.getDataModel()
             field_id = self.fields[0]
-            content_url = "/viewimage?path=%s/%s_%s.jpg" %\
-                                    (self.path,
-                                    datastructure[self.id_field],
-                                    self.getWidgetId(),
-                                    )
+            screening_type = datastructure.get('screening_type')
             current_filename = "%s_%s.jpg" % (datastructure[self.id_field],
                                             field_id,)
-            file_path = "/%s/%s" % (self.storage_path,
-                                        current_filename)
+            base_path = os.path.join(screening_type,current_filename)
+            content_url = os.path.join('viewimage',self.path,base_path)
+            file_path = os.path.join(self.storage_path,base_path)
+            #import pdb; pdb.set_trace()
         else:
             file_path = "XXX"
@@ -1610,5 +1639,4 @@
     ###)
 
-
     def checkFileName(self, filename, mimetype):
         return '', {}
@@ -1625,4 +1653,8 @@
         if self.allow_resize:
             datastructure[self.getWidgetId() + '_resize'] = ''
+        screening_type = datamodel.get('screening_type',None)
+        if not screening_type:
+            screening_type = self.REQUEST.form.get('screening_type','pume')
+        datastructure["screening_type"] = screening_type
         datastructure[widget_id] = file_name
         datastructure[widget_id + '_choice'] = 'change'
@@ -1634,5 +1666,5 @@
         """Update datamodel from user data in datastructure.
         """
-        logger = logging.getLogger('Widgets.NoZodbImageWidget.validate')
+        logger = logging.getLogger('Widgets.ApplicationImageWidget.validate')
         datamodel = datastructure.getDataModel()
         field_id = self.fields[0]
@@ -1694,7 +1726,8 @@
         if is_upload and store:
             ext ='jpg'
+            screening_type = datastructure.get('screening_type')
             filename = "%s_%s.%s" % (datastructure[self.id_field],
-                                 self.getWidgetId(),
-                                 ext)
+                                     self.getWidgetId(),
+                                     ext)
             datamodel[field_id] = filename
             registry = getToolByName(self, 'mimetypes_registry')
@@ -1702,9 +1735,4 @@
             if mimetype is not None:
                 mimetype = str(mimetype) # normalize
-            # Set/update data
-            # file_path = "%s_%s.jpg" % (datamodel[self.id_field],
-            #                            field_id,)
-            full_path = "%s/%s" % (self.storage_path, filename)
-            #import pdb; pdb.set_trace()
             file = self.makeFile(filename, fileupload, datastructure)
             # Fixup mimetype
@@ -1712,7 +1740,9 @@
                 file.content_type = mimetype
             # Store the file in the filesystem
-            if not os.path.exists(self.storage_path):
-                os.mkdir(self.storage_path)
             #import pdb;pdb.set_trace()
+            base_path = os.path.join(self.storage_path, screening_type)
+            if not os.path.exists(base_path):
+                os.mkdir(base_path)
+            full_path = os.path.join(base_path, file_name)
             pict = open(full_path,"w")
             fileupload.seek(0)
@@ -1735,7 +1765,7 @@
     ###)
 
-InitializeClass(NoZodbImageWidget)
-
-widgetRegistry.register(NoZodbImageWidget)
+InitializeClass(ApplicationImageWidget)
+
+widgetRegistry.register(ApplicationImageWidget)
 ###)
 
@@ -1749,9 +1779,12 @@
      {'id': 'id_field', 'type': 'string', 'mode': 'w',
       'label': 'Field to build the id'},
+     {'id': 'show_image', 'type': 'boolean', 'mode': 'w',
+      'label': 'Show Image'},
     )
     path = "images"
     storage_path = "%s/%s" % (i_home,path)
     id_field = ""
-
+    show_image = False
+    
     def getImageInfo(self, datastructure): ###(
         """Get the file info from the datastructure."""
@@ -1851,4 +1884,5 @@
         image_info['width'] = width
         image_info['image_tag'] = tag
+        image_info['show_image'] = self.show_image
         return image_info
     ###)
@@ -1985,4 +2019,5 @@
         render_method = 'widget_image_render'
         meth = getattr(self, render_method, None)
+        #import pdb;pdb.set_trace()
         if meth is None:
             raise RuntimeError("Unknown Render Method %s for widget type %s"
Index: /WAeUP_SRP/base/skins/cps_custom/widget_image_render.pt
===================================================================
--- /WAeUP_SRP/base/skins/cps_custom/widget_image_render.pt	(revision 2341)
+++ /WAeUP_SRP/base/skins/cps_custom/widget_image_render.pt	(revision 2342)
@@ -1,28 +1,28 @@
 <tal:block define="mode options/mode;
-  id here/getWidgetId;
-  fields here/fields;
-  current_filename options/current_filename;
-  empty_file options/empty_file;
-  session_file options/session_file;
-  mimetype options/mimetype;
-  size options/size;
-  content_url options/content_url;
-  last_modified options/last_modified;
-  content_url_nocache string:${content_url}?nocache=${last_modified};
-  image_width options/width;
-  image_height options/height;
-  image_tag options/image_tag;
-  ">
-<span tal:condition="python:0">
-  <img tal:condition="python: mode == 'view' and not empty_file"
-    tal:replace="structure image_tag" />
-</span>
-<span tal:condition="python: mode == 'view' and not empty_file">
-  <a href="" target="_new" 
-     tal:attributes="href content_url"
-     tal:content="current_filename" >
-  </a>
-</span>
-
+           id here/getWidgetId;
+           fields here/fields;
+           current_filename options/current_filename;
+           empty_file options/empty_file;
+           session_file options/session_file;
+           mimetype options/mimetype;
+           size options/size;
+           content_url options/content_url;
+           last_modified options/last_modified;
+           content_url_nocache string:${content_url}?nocache=${last_modified};
+           image_width options/width;
+           image_height options/height;
+           image_tag options/image_tag;
+           show_image options/show_image|nothing;"
+           >
+  <span tal:condition="python: mode == 'view' and not empty_file" tal:omit-tag="">
+    <img tal:condition="python: show_image"
+         tal:replace="structure image_tag" />
+    <span tal:condition="python: not show_image" tal:omit-tag="">
+      <a href="" target="_new" 
+         tal:attributes="href content_url"
+         tal:content="current_filename" >
+      </a>
+    </span>
+  </span>
   <tal:block condition="python: mode == 'edit'">
 
Index: /WAeUP_SRP/uniben/profiles/default/layouts/application_manage.xml
===================================================================
--- /WAeUP_SRP/uniben/profiles/default/layouts/application_manage.xml	(revision 2341)
+++ /WAeUP_SRP/uniben/profiles/default/layouts/application_manage.xml	(revision 2342)
@@ -324,5 +324,5 @@
     <property name="css_class_expr">string:row</property>
   </widget>
-  <widget name="passport" meta_type="No Zodb Image Widget">
+  <widget name="passport" meta_type="Application Image Widget">
     <property name="title">Passport Photograph</property>
     <property name="fields">
Index: /WAeUP_SRP/uniben/profiles/default/layouts/application_pce.xml
===================================================================
--- /WAeUP_SRP/uniben/profiles/default/layouts/application_pce.xml	(revision 2341)
+++ /WAeUP_SRP/uniben/profiles/default/layouts/application_pce.xml	(revision 2342)
@@ -324,5 +324,5 @@
     <property name="css_class_expr">string:row</property>
   </widget>
-  <widget name="passport" meta_type="No Zodb Image Widget">
+  <widget name="passport" meta_type="Application Image Widget">
     <property name="title">Passport Photograph</property>
     <property name="fields">
Index: /WAeUP_SRP/uniben/profiles/default/layouts/application_pde.xml
===================================================================
--- /WAeUP_SRP/uniben/profiles/default/layouts/application_pde.xml	(revision 2341)
+++ /WAeUP_SRP/uniben/profiles/default/layouts/application_pde.xml	(revision 2342)
@@ -388,5 +388,5 @@
     <property name="css_class_expr">string:row</property>
   </widget>
-  <widget name="passport" meta_type="No Zodb Image Widget">
+  <widget name="passport" meta_type="Application Image Widget">
     <property name="title">Passport Photograph</property>
     <property name="fields">
Index: /WAeUP_SRP/uniben/profiles/default/layouts/application_prence.xml
===================================================================
--- /WAeUP_SRP/uniben/profiles/default/layouts/application_prence.xml	(revision 2341)
+++ /WAeUP_SRP/uniben/profiles/default/layouts/application_prence.xml	(revision 2342)
@@ -360,5 +360,5 @@
     <property name="css_class_expr">string:row</property>
   </widget>
-  <widget name="passport" meta_type="No Zodb Image Widget">
+  <widget name="passport" meta_type="Application Image Widget">
     <property name="title">Passport Photograph</property>
     <property name="fields">
Index: /WAeUP_SRP/uniben/profiles/default/layouts/application_pume.xml
===================================================================
--- /WAeUP_SRP/uniben/profiles/default/layouts/application_pume.xml	(revision 2341)
+++ /WAeUP_SRP/uniben/profiles/default/layouts/application_pume.xml	(revision 2342)
@@ -326,5 +326,5 @@
     <property name="css_class_expr">string:row</property>
   </widget>
-  <widget name="passport" meta_type="No Zodb Image Widget">
+  <widget name="passport" meta_type="Application Image Widget">
     <property name="title">Passport Photograph</property>
     <property name="fields">
Index: /WAeUP_SRP/uniben/profiles/default/layouts/student_application.xml
===================================================================
--- /WAeUP_SRP/uniben/profiles/default/layouts/student_application.xml	(revision 2341)
+++ /WAeUP_SRP/uniben/profiles/default/layouts/student_application.xml	(revision 2342)
@@ -274,5 +274,6 @@
   <property name="display_width">150</property>
   <property name="display_height">200</property>
- </widget>
+  <property name="show_image">True</property>
+  </widget>
  <table>
   <row>
Index: /WAeUP_SRP/uniben/profiles/default/layouts/student_application_fe.xml
===================================================================
--- /WAeUP_SRP/uniben/profiles/default/layouts/student_application_fe.xml	(revision 2341)
+++ /WAeUP_SRP/uniben/profiles/default/layouts/student_application_fe.xml	(revision 2342)
@@ -263,4 +263,5 @@
   <property name="display_height">200</property>
   <property name="allow_resize">True</property>
+  <property name="show_image">True</property>
  </widget>
  <table>
