src/pyams_sequence/sequence.py
changeset 13 b3d0c3b4c940
parent 0 980ffaa51a75
child 38 f3acef84eef9
equal deleted inserted replaced
12:7ffbf5c15128 13:b3d0c3b4c940
    14 
    14 
    15 
    15 
    16 # import standard library
    16 # import standard library
    17 
    17 
    18 # import interfaces
    18 # import interfaces
    19 from pyams_sequence.interfaces import ISequentialIdInfo, ISequentialIdTarget
    19 from pyams_sequence.interfaces import ISequentialIdInfo, ISequentialIdTarget, ISequentialIntIds
    20 from zope.annotation.interfaces import IAnnotations
    20 from zope.annotation.interfaces import IAnnotations
    21 
    21 
    22 # import packages
    22 # import packages
    23 from persistent import Persistent
    23 from persistent import Persistent
    24 from pyams_utils.adapter import adapter_config
    24 from pyams_utils.adapter import adapter_config
       
    25 from pyams_utils.registry import get_utility
    25 from zope.interface import implementer
    26 from zope.interface import implementer
    26 from zope.schema.fieldproperty import FieldProperty
    27 from zope.schema.fieldproperty import FieldProperty
    27 
    28 
    28 
    29 
    29 @implementer(ISequentialIdInfo)
    30 @implementer(ISequentialIdInfo)
    30 class SequentialIdInfo(Persistent):
    31 class SequentialIdInfo(Persistent):
    31     """Sequential ID info"""
    32     """Sequential ID info"""
    32 
    33 
    33     oid = FieldProperty(ISequentialIdInfo['oid'])
    34     oid = FieldProperty(ISequentialIdInfo['oid'])
    34     hex_oid = FieldProperty(ISequentialIdInfo['hex_oid'])
    35     hex_oid = FieldProperty(ISequentialIdInfo['hex_oid'])
       
    36 
       
    37     def get_full_oid(self):
       
    38         sequence = get_utility(ISequentialIntIds)
       
    39         return sequence.get_full_oid(self.oid)
       
    40 
       
    41     def get_short_oid(self):
       
    42         sequence = get_utility(ISequentialIntIds)
       
    43         return sequence.get_short_oid(self.oid)
       
    44 
       
    45     def get_base_oid(self):
       
    46         sequence = get_utility(ISequentialIntIds)
       
    47         return sequence.get_base_oid(self.oid)
    35 
    48 
    36 
    49 
    37 SEQUENCE_INFO_KEY = 'pyams_sequence.info'
    50 SEQUENCE_INFO_KEY = 'pyams_sequence.info'
    38 
    51 
    39 
    52