src/pyams_utils/interfaces/__init__.py
branchdev-tf
changeset 427 63284c98cdc1
parent 367 2c95d34496f5
equal deleted inserted replaced
426:2022e4da3ad9 427:63284c98cdc1
     8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
     9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
    10 # FOR A PARTICULAR PURPOSE.
    10 # FOR A PARTICULAR PURPOSE.
    11 #
    11 #
    12 
    12 
    13 """PyAMS_utils interfaces module
    13 """PyAMS_utils.interfaces package
    14 
    14 
    15 This module defines several generic constants and interfaces.
    15 This module defines several generic constants and interfaces.
       
    16 
    16 It is also used to provide translations to common zope.schema exceptions.
    17 It is also used to provide translations to common zope.schema exceptions.
    17 """
    18 """
    18 
    19 
       
    20 from zope.interface import Interface
       
    21 from zope.schema.interfaces import ConstraintNotSatisfied, InvalidDottedName, InvalidId, \
       
    22     InvalidURI, InvalidValue, NotAContainer, NotAnIterator, NotUnique, RequiredMissing, \
       
    23     SchemaNotFullyImplemented, SchemaNotProvided, TooBig, TooLong, TooShort, TooSmall, Unbound, \
       
    24     WrongContainedType, WrongType
       
    25 
    19 __docformat__ = 'restructuredtext'
    26 __docformat__ = 'restructuredtext'
    20 
       
    21 from zope.interface import Interface
       
    22 from zope.schema.interfaces import ConstraintNotSatisfied, InvalidDottedName, InvalidId, InvalidURI, InvalidValue, \
       
    23     NotAContainer, NotAnIterator, NotUnique, RequiredMissing, SchemaNotFullyImplemented, SchemaNotProvided, TooBig, \
       
    24     TooLong, TooShort, TooSmall, Unbound, WrongContainedType, WrongType
       
    25 
    27 
    26 from pyams_utils import _
    28 from pyams_utils import _
    27 
    29 
    28 
    30 
    29 #
    31 #
    48 InvalidValue.__doc__ = _("""Invalid value""")
    50 InvalidValue.__doc__ = _("""Invalid value""")
    49 ConstraintNotSatisfied.__doc__ = _("""Constraint not satisfied""")
    51 ConstraintNotSatisfied.__doc__ = _("""Constraint not satisfied""")
    50 NotAContainer.__doc__ = _("""Not a container""")
    52 NotAContainer.__doc__ = _("""Not a container""")
    51 NotAnIterator.__doc__ = _("""Not an iterator""")
    53 NotAnIterator.__doc__ = _("""Not an iterator""")
    52 
    54 
    53 
       
    54 #
    55 #
    55 # Custom permissions
    56 # Custom permissions
    56 #
    57 #
    57 
    58 
    58 FORBIDDEN_PERMISSION = 'system.forbidden'
    59 FORBIDDEN_PERMISSION = 'system.forbidden'
    63 
    64 
    64 VIEW_PERMISSION = 'view'
    65 VIEW_PERMISSION = 'view'
    65 '''View permission is a custom permission used to view contents'''
    66 '''View permission is a custom permission used to view contents'''
    66 
    67 
    67 MANAGE_PERMISSION = 'manage'
    68 MANAGE_PERMISSION = 'manage'
    68 '''Permission used to manage basic information; this permission is generally not used by custom contents'''
    69 '''Permission used to manage basic information; this permission is generally not used by custom
       
    70 contents'''
    69 
    71 
    70 VIEW_SYSTEM_PERMISSION = 'pyams.ViewSystem'
    72 VIEW_SYSTEM_PERMISSION = 'pyams.ViewSystem'
    71 '''Permission used to access management screens'''
    73 '''Permission used to access management screens'''
    72 
    74 
    73 MANAGE_SYSTEM_PERMISSION = 'pyams.ManageSystem'
    75 MANAGE_SYSTEM_PERMISSION = 'pyams.ManageSystem'
   104 class IObjectFactory(Interface):
   106 class IObjectFactory(Interface):
   105     """Object factory interface
   107     """Object factory interface
   106 
   108 
   107     This interface can be used to register an "interface's object factory".
   109     This interface can be used to register an "interface's object factory".
   108     For a given interface, such factory can be used to get an instance of an object providing
   110     For a given interface, such factory can be used to get an instance of an object providing
   109     this interface; several factories can be registered for the same interface if they have distinct
   111     this interface; several factories can be registered for the same interface if they have
   110     names. See :py:mod:`pyams_utils.factory` module.
   112     distinct names. See :py:mod:`pyams_utils.factory` module.
   111     """
   113     """
   112 
   114 
   113 
   115 
   114 class ICacheKeyValue(Interface):
   116 class ICacheKeyValue(Interface):
   115     """Interface used to get string representation of a given object as cache key
   117     """Interface used to get string representation of a given object as cache key
   116 
   118 
   117     Several default adapters are given for objects (using their "id()"), strings (using string as key)
   119     Several default adapters are given for objects (using their "id()"), strings (using string as
   118     and for persistent objects (using their persistent OID); you are free to provide your own adapters.
   120     key) and for persistent objects (using their persistent OID); you are free to provide your
       
   121     own adapters.
   119     """
   122     """