Logo Search packages:      
Sourcecode: zope-attachmentfield version File versions  Download package

def AttachmentField::AttachmentService::AttachmentService::testFileIndexing (   self,
  file,
  output_encoding 
)

testFileIndexing(self, file, output_encoding) => dict
the dict keys are :
  - content_type: MIME type
  - content_length: length
  - filename: filename (!)
  - raw_content: file.read()
  - index: indexable value
  - preview: html preview
  - encoding: same as output_encoding
  - obj: Typeless object
handler id and output encoding must be provided.
WARNING: 'handler' parameter is deprecated.

Definition at line 168 of file AttachmentService.py.

00168                                                      :
        """
        testFileIndexing(self, file, output_encoding) => dict
        the dict keys are :
          - content_type: MIME type
          - content_length: length
          - filename: filename (!)
          - raw_content: file.read()
          - index: indexable value
          - preview: html preview
          - encoding: same as output_encoding
          - obj: Typeless object
        handler id and output encoding must be provided.
        WARNING: 'handler' parameter is deprecated.
        """
        # Create a dummy object and fakely upload an attachment
        obj = TypelessAttachmentField.getTypelessAttachmentField(self)
        obj.Schema().updateAll(obj, file = file, )
        filefield = obj.getField('file')
        content_type = string.lower(file.headers['Content-Type'])
        filename = file.filename

        # Process what happens
        content = filefield.get(obj)
        filename = filefield.getFilename(obj)
        handler_mime = filefield.getContentType(obj)
        content_length = filefield.getSize(obj)
        index = filefield.getIndexableValue(obj)
        preview = filefield.getPreview(obj)
        icon_path = filefield.getIcon(obj)
        small_icon_path = filefield.getSmallIcon(obj)
        handler = filefield._getHandler(obj).__class__.__name__

        # Mangle some results to make them clearer
        if index:
            index_sample = index[:INDEX_SAMPLE_LENGTH]
            index = "%d words." % (
                len(string.split(index)),
                )
        else:
            index_sample = "(unavailable)"
            index = "(No index generated)"
        if not preview:
            preview = "(unavailable)"

        # Return a pretty results structure
        return {
            "content_type": content_type,
            "content_length": content_length,
            "filename": filename,
            "handler": handler,
            "handler_mime": handler_mime,
            "index": index,
            "index_sample": index_sample,
            "preview": preview,
            "encoding": output_encoding,
            "icon_path": icon_path,
            "small_icon_path": small_icon_path,
            "obj": obj,
            }

    security.declareProtected(view_management_screens, "_old_testFileIndexing")
    def _old_testFileIndexing(self, file, handler, output_encoding):


Generated by  Doxygen 1.6.0   Back to index