Total Complexity | 4 |
Total Lines | 24 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | # -*- coding: utf-8 -*- |
||
2 | |||
3 | import re |
||
4 | |||
5 | from Acquisition import aq_inner |
||
6 | from Acquisition import aq_parent |
||
7 | from bika.lims import api |
||
8 | from senaite.core import logger |
||
9 | |||
10 | TMP_RX = re.compile("[a-z0-9]{32}$") |
||
11 | |||
12 | |||
13 | def is_tmp_id(id): |
||
14 | return TMP_RX.match(id) |
||
15 | |||
16 | |||
17 | def isTemporary(self): |
||
18 | parent = aq_parent(aq_inner(self)) |
||
19 | # Fix indexing of temporary objects resulting in orphan entries in catalog |
||
20 | if is_tmp_id(self.id) or is_tmp_id(parent.id): |
||
21 | logger.debug("DX object %s is temporary!" % api.get_path(self)) |
||
22 | return True |
||
23 | return False |
||
24 |