| Total Complexity | 3 |
| Total Lines | 24 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 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 |