Example #1
0
 def get_item_value(self, resource, context, item, column):
     if column == 'img_path':
         img_path = resource.handler.get_record_value(item, column)
         # NOTE img_path is unicode multiple -> multilingual
         image = resource.get_resource(str(img_path), soft=True)
         if not image:
             return None
         return get_resource_preview(image, 128, 64, 0, context)
     elif column == 'img_link':
         img_link = resource.handler.get_record_value(item, column)
         reference = get_reference(img_link)
         if reference.scheme:
             # Encode the reference '&' to avoid XMLError
             reference = XMLContent.encode(str(reference))
             return XMLParser('<a href="%s">%s</a>' % (reference, reference))
         # Split path/view
         reference_path = str(reference.path)
         view = None
         if reference_path.count(';'):
             reference_path, view = reference_path.split('/;' ,1)
         item_resource = resource.get_resource(reference_path, soft=True)
         if not item_resource:
             # Not found, just return the reference
             # Encode the reference '&' to avoid XMLError
             return XMLContent.encode(str(reference))
         # Build the new reference with the right path
         reference2 = deepcopy(reference)
         reference2.path = context.get_link(item_resource)
         if view:
             # Append the view
             reference2.path = '%s/;%s' % (reference2.path, view)
         # Encode the reference '&' to avoid XMLError
         # Reference : the reference used for the a content
         reference = XMLContent.encode(str(reference))
         # Reference2 : the reference used for href attribute
         reference2 = XMLContent.encode(str(reference2))
         return XMLParser('<a href="%s">%s</a>' % (reference2, reference))
     return Table_View.get_item_value(self, resource, context, item, column)
Example #2
0
 def get_item_value(self, resource, context, item, column):
     if column == 'img_path':
         img_path = resource.handler.get_record_value(item, column)
         image = resource.get_resource(str(img_path), soft=True)
         if not image:
             return None
         return get_resource_preview(image, 128, 64, 0, context)
     elif column == 'img_link':
         img_link = resource.handler.get_record_value(item, column)
         reference = get_reference(img_link)
         if isinstance(reference, EmptyReference):
             return None
         if reference.scheme:
             # Encode the reference '&' to avoid XMLError
             ref = XMLContent.encode(str(reference))
             return XMLParser('<a href="{ref}">{ref}</a>'.format(ref=ref))
         # Split path/view
         reference_path, view = get_path_and_view(reference.path)
         item_resource = resource.get_resource(reference_path, soft=True)
         if not item_resource:
             # Not found, just return the reference
             # Encode the reference '&' to avoid XMLError
             return XMLContent.encode(str(reference))
         # Build the new reference with the right path
         reference2 = deepcopy(reference)
         reference2.path = context.get_link(item_resource)
         if view:
             # Append the view
             reference2.path = '%s/;%s' % (reference2.path, view)
         # Encode the reference '&' to avoid XMLError
         # Reference : the reference used for the a content
         reference = XMLContent.encode(str(reference))
         # Reference2 : the reference used for href attribute
         reference2 = XMLContent.encode(str(reference2))
         return XMLParser('<a href="%s">%s</a>' % (reference2, reference))
     return OrderedTable_View.get_item_value(self, resource, context, item,
                                             column)