Passed
Push — 2.x ( b772fa...0eee09 )
by Jordi
06:00
created

senaite.core.patches.catalog   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 22
dl 0
loc 33
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
B catalog_object() 0 25 6
1
# -*- coding: utf-8 -*-
2
3
from plone.indexer.interfaces import IIndexableObject
4
from Products.ZCatalog.ZCatalog import ZCatalog
5
from zope.component import queryMultiAdapter
6
7
8
def catalog_object(self, object, uid=None, idxs=None,
9
                   update_metadata=1, pghandler=None):
10
11
    try:
12
        # Never catalog temporary objects
13
        temporary = object.isTemporary()
14
        if temporary is True:
15
            return
16
    except AttributeError:
17
        pass
18
19
    if idxs is None:
20
        idxs = []
21
    self._increment_counter()
22
23
    w = object
24
    if not IIndexableObject.providedBy(object):
25
        # This is the CMF 2.2 compatible approach, which should be used
26
        # going forward
27
        wrapper = queryMultiAdapter((object, self), IIndexableObject)
28
        if wrapper is not None:
29
            w = wrapper
30
31
    ZCatalog.catalog_object(self, w, uid, idxs,
32
                            update_metadata, pghandler=pghandler)
33