Passed
Pull Request — 2.x (#1865)
by Ramon
05:22
created

senaite.core.patches   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 14
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A isFactoryContained() 0 11 3
1
# -*- coding: utf-8 -*-
2
3
from Acquisition import aq_base
4
from Acquisition import aq_inner
5
from Acquisition import aq_parent
6
from Products.Archetypes import utils
7
8
9
def isFactoryContained(obj):
10
    """Are we inside the portal_factory?
11
    """
12
    if obj.isTemporary():
13
        return True
14
    parent = aq_parent(aq_inner(obj))
15
    if parent is None:
16
        # We don't have enough context to know where we are
17
        return False
18
    meta_type = getattr(aq_base(parent), "meta_type", "")
19
    return meta_type == "TempFolder"
20
21
22
# https://pypi.org/project/collective.monkeypatcher/#patching-module-level-functions 
23
utils.isFactoryContained = isFactoryContained
24