FileSystemStorage is an Archetypes storage for storing data on FileSystem.
This storage is used to avoid ZODB to grow quickly when using a lot of large files.

Dependencies

  - Zope 2.7.4+
  
  - Plone 2.0+
  
  - Archetypes 1.3+

How to install it ?

  - Put FileSystemStorage product in your zope instance Products directory
 
  - Restart you zope instance
  
  - In ZMI, go into your plone site and install the product using portal_quickinstaller

How to configure it ?
  
  Paths
  
    Data are stored on filesystem. You need to specify the directory on your filesystem 
    where you want to store data.
  
    You must specify 2 locations :
  
    - storage directory where all data will be stored
  
    - backup directory where all data will be backuped
  
    Backups are very useful : users can undo a deletion action on a FSS field
  
    To configure paths :

    - Go to plone control panel

    - Go to FileSystemStorage preferences configlet

    - In management tab, just configure storage and backup paths

    **WARNING:** Make sure zope process have write permissions on locations.

  RDF

    RDF is a way to export some readable informations about FSS files.
    For example, you can export :

    - Title

    - Description

    - Creator

    - ...

    If you want FSS to automatically build RDF files, just do this:

    - Go to plone control panel

    - Go to FileSystemStorage preferences configlet

    - In management tab, just check box "RDF enabled ?"

How to maintain it ?  


  Users can do some maintenance operations on FSS.
  All these tasks can be done doing this :

  - Go to plone control panel

  - Go to FileSystemStorage preferences configlet

  - Go to maintenance tab

  Statistics

    A readable table gives to the plone administrator some useful informations:

    - valid files: FSS files used in plone instance and existing in storage path

    - valid backups: FSS backups existing in backup path and not used in plone instance

    - not valid files: FSS files not used in plone instance and existing in storage path

    - not valid backups: FSS files used in plone instance and existing in backup_path

    - Total size: Total size of FSS files

    - Max size: Max FSS file size

    - Min size: Min FSS file size

    - Average size: Average FSS file size

  Update FSS files

    Not valid files are moved in backup path and not valid backups are moved in storage path.

  Remove backups

    This is useful to remove backups older than a number of days you can specify.

  Update RDF files

    Build all rdf files. Disabling rdf in management tab don't break building.

Developers

  How to use it in python ?

    FSS storage are used on Archetypes field.
    If you want to store a field data on file system, just do this :

    - Import FSS storage

    - Add storage definition in your field
    
    Example ::
    
      from Products.FileSystemStorage.FileSystemStorage import FileSystemStorage
      
      my_schema = Schema((
          FileField('file',
              ...
              storage=FileSystemStorage(),
              widget=FileWidget(...)
              ),
          ))
      

  How to add custom RDF informations ?

    First you need to specify the name of a script which can be accessed in acquisition 
    by your plone site instance.

    Input script parameters :

    - name: name of the field

    - instance: content using a FSS field

    - properties: FSS field properties (filename, size, mimetype, width, height)

    - default_rdf: Default RDF structure returned by FSS

    Simple RDF script ::
    
      from DateTime import DateTime

      def getRDF(name, instance, properties, default_rdf):
          """Returns a rdf structure used by FSS to generate RDF files"

          rdf_args = default_rdf.copy()
        
          # Add the date of RDF generation
          new_props = []
          new_props.extend(rdf_args['field_props'])
          new_props.append({'id': 'fss:rdf_date', 'value': DateTime().ISO()})
          rdf_args['field_props'] = new_props
	
          # Returns the RDF structure
          return rdf_args


    More complex RDF script ::

      from Products.CMFCore.utils import getToolByName

      def getRDF(name, instance, properties, default_rdf):
          """Returns a rdf structure used by FSS to generate RDF files"

          rdf_args = {}
	
          # Set RDF charset
          ptool = getToolByName(instance, 'portal_properties')
          rdf_args['charset'] = ptool.site_properties.default_charset
        
          # Set RDF namespaces
          rdf_args['namespaces'] = (
              {'id': 'xmlns:rdf', 'value': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'},
              {'id': 'xmlns:dc', 'value': 'http://purl.org/dc/elements/1.1/'},
              {'id': 'xmlns:fss', 'value': 'http://namespace.ingeniweb.com/fss'},) 
        
          # Set field url
          utool = getToolByName(instance, 'portal_url')
          portal_path = utool.getPortalObject().getPhysicalPath()
          portal_path_len = len(portal_path)
          rel_path = '/'.join(instance.getPhysicalPath()[portal_path_len:])
          fss_path = '%s/fss_get/%s' % (rel_path, name)
          rdf_args['field_url'] = fss_path
        
          # Set RDF properties
          props = (
	         {'id': 'dc:title', 'value': instance.title_or_id()},
	         {'id': 'dc:description', 'value': instance.Description()},
	         {'id': 'dc:language', 'value': instance.Language()},
	         {'id': 'dc:creator', 'value': instance.Creator()},
	         {'id': 'dc:date', 'value': instance.modified()},
	         {'id': 'dc:format', 'value': properties.get('mimetype', 'text/plain')},
	         )
          rdf_args['field_props'] = props
	
	      # Returns the RDF structure
          return rdf_args

System administrator

  System administrator can export the FSS files in a readable filesystem tree.
  The bin directory of FileSystemStorage products contains a python script used 
  to export FSS files.

  To use it just do this ::
  
    cd $INSTANCE/Products/FileSystemStorage/bin
    python build_fs_tree.py $FSS_STORAGE_PATH $DST_PATH

Credits

  The http://wwww.ingeniweb.com:"ingeniweb" team

Check for newer version

  Release: http://www.plone.org/products/filesystemstorage
  
  * kwargs = {}
    kwargs['charset'] = 'utf-8'
    kwargs['namespaces'] = (
        {'id': 'xmlns:rdf', 'value': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'},
        {'id': 'xmlns:dc', 'value': 'http://purl.org/dc/elements/1.1/'},
        {'id': 'xmlns:fss', 'value': 'http://namespace.ingeniweb.com/fss'},) 
    kwargs['field_url'] = 'url/du/champ/relative/Ã /la/racine/du/site'
    kwargs['field_props'] = (
        {'id': 'dc:title', 'value': 'Titre du contenu'},
        {'id': 'dc:language', 'value': 'Langue du contenu'},
        {'id': 'dc:creator', 'value': "Nom de l'utilisateur ayant crÃ©Ã© ou modifiÃ© le champ texte"},
        {'id': 'dc:date', 'value': "DerniÃ¨re date de modification du champ texte au format ISO"},
        {'id': 'dc:format', 'value': "text/plain"},
        {'id': 'fss:size', 'value': "Taille du texte en octets"},
        )

  SVN repository: http://svn.plone.org/svn/collective/FileSystemStorage
  
