src/pyams_file/interfaces/__init__.py
changeset 176 4eb49f19314a
parent 117 2d6c635c323f
child 195 07c9c58698fb
equal deleted inserted replaced
175:ab573883a5c7 176:4eb49f19314a
    10 # FOR A PARTICULAR PURPOSE.
    10 # FOR A PARTICULAR PURPOSE.
    11 #
    11 #
    12 
    12 
    13 __docformat__ = 'restructuredtext'
    13 __docformat__ = 'restructuredtext'
    14 
    14 
    15 
       
    16 # import standard library
       
    17 
       
    18 # import interfaces
       
    19 from z3c.form.interfaces import IFileWidget as IBaseFileWidget
    15 from z3c.form.interfaces import IFileWidget as IBaseFileWidget
    20 from zope.annotation.interfaces import IAttributeAnnotatable
    16 from zope.annotation.interfaces import IAttributeAnnotatable
       
    17 from zope.interface import Attribute, Interface, implementer
       
    18 from zope.lifecycleevent import ObjectModifiedEvent
    21 from zope.lifecycleevent.interfaces import IObjectModifiedEvent
    19 from zope.lifecycleevent.interfaces import IObjectModifiedEvent
       
    20 from zope.schema import Bytes, BytesLine, Choice, Int, Text, TextLine
    22 from zope.schema.interfaces import IBytes
    21 from zope.schema.interfaces import IBytes
    23 
    22 
    24 # import packages
       
    25 from zope.interface import implementer, Interface, Attribute
       
    26 from zope.lifecycleevent import ObjectModifiedEvent
       
    27 from zope.schema import Bytes, BytesLine, Int, Text, TextLine, Choice
       
    28 
       
    29 from pyams_file import _
    23 from pyams_file import _
       
    24 
       
    25 
       
    26 #
       
    27 # Blobs references manager
       
    28 #
       
    29 
       
    30 class IBlobReferenceManager(Interface):
       
    31     """Blobs references manager
       
    32 
       
    33     This utility interface is used to manage references to blobs: each file contains a
       
    34     link to a ZODB "Blob" object which is used to store it's data; when a content is duplicated,
       
    35     all it's blobs references are updated but the blob itself is not duplicated to reduce space usage.
       
    36     As long as a blob data is not modified, the same content can be shared between several versions
       
    37     of a same content. So it's only when all references to a given blob have been removed that
       
    38     the blob file is deleted and can be garbaged collected.
       
    39     """
       
    40 
       
    41     def add_reference(self, blob, reference):
       
    42         """Add a reference to given blob"""
       
    43 
       
    44     def drop_reference(self, blob, reference):
       
    45         """Remove reference from given blob
       
    46 
       
    47         Blob is deleted if no more referenced.
       
    48         """
    30 
    49 
    31 
    50 
    32 #
    51 #
    33 # Main file objects interfaces
    52 # Main file objects interfaces
    34 #
    53 #
    60     def get_size(self):
    79     def get_size(self):
    61         """Returns the byte-size of object's data"""
    80         """Returns the byte-size of object's data"""
    62 
    81 
    63     def get_blob(self, mode='r'):
    82     def get_blob(self, mode='r'):
    64         """Get Blob file associated with this object"""
    83         """Get Blob file associated with this object"""
       
    84 
       
    85     def add_blob_reference(self, reference):
       
    86         """Add a reference to file internal blob"""
       
    87 
       
    88     def free_blob(self):
       
    89         """Free blob associated with this object"""
    65 
    90 
    66 
    91 
    67 class IMediaFile(IFile):
    92 class IMediaFile(IFile):
    68     """Multimedia file"""
    93     """Multimedia file"""
    69 
    94