--- a/src/pyams_sequence/interfaces/__init__.py Wed Jul 12 17:45:40 2017 +0200
+++ b/src/pyams_sequence/interfaces/__init__.py Mon Sep 11 13:59:19 2017 +0200
@@ -53,6 +53,9 @@
def get_short_oid(self, oid, obj_prefix=None):
"""Get short ID based on given numeric object ID"""
+ def get_base_oid(self, oid, obj_prefix=None):
+ """Get base ID (without prefix) based on given numeric object ID"""
+
def get_internal_id(self, oid):
"""Get internal ID matching given OID"""
@@ -69,8 +72,14 @@
hex_oid = TextLine(title=_("Unique ID"),
required=False)
+ def get_full_oid(self):
+ """Get full OID"""
+
def get_short_oid(self):
- """Get short ID"""
+ """Get short OID"""
+
+ def get_base_oid(self):
+ """Get base OID"""
class ISequentialIdTarget(IAttributeAnnotatable):
--- a/src/pyams_sequence/sequence.py Wed Jul 12 17:45:40 2017 +0200
+++ b/src/pyams_sequence/sequence.py Mon Sep 11 13:59:19 2017 +0200
@@ -16,12 +16,13 @@
# import standard library
# import interfaces
-from pyams_sequence.interfaces import ISequentialIdInfo, ISequentialIdTarget
+from pyams_sequence.interfaces import ISequentialIdInfo, ISequentialIdTarget, ISequentialIntIds
from zope.annotation.interfaces import IAnnotations
# import packages
from persistent import Persistent
from pyams_utils.adapter import adapter_config
+from pyams_utils.registry import get_utility
from zope.interface import implementer
from zope.schema.fieldproperty import FieldProperty
@@ -33,6 +34,18 @@
oid = FieldProperty(ISequentialIdInfo['oid'])
hex_oid = FieldProperty(ISequentialIdInfo['hex_oid'])
+ def get_full_oid(self):
+ sequence = get_utility(ISequentialIntIds)
+ return sequence.get_full_oid(self.oid)
+
+ def get_short_oid(self):
+ sequence = get_utility(ISequentialIntIds)
+ return sequence.get_short_oid(self.oid)
+
+ def get_base_oid(self):
+ sequence = get_utility(ISequentialIntIds)
+ return sequence.get_base_oid(self.oid)
+
SEQUENCE_INFO_KEY = 'pyams_sequence.info'
--- a/src/pyams_sequence/utility.py Wed Jul 12 17:45:40 2017 +0200
+++ b/src/pyams_sequence/utility.py Mon Sep 11 13:59:19 2017 +0200
@@ -131,6 +131,10 @@
obj_prefix=obj_prefix or '',
hex_id=oid)
+ def get_base_oid(self, oid, obj_prefix=None):
+ return '{obj_prefix} {hex_id:x}'.format(obj_prefix=obj_prefix or '',
+ hex_id=oid)
+
def get_internal_id(self, oid):
if oid.startswith('+'):
oid = oid[1:]