• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zopefoundation / Zope / 3956162881

pending completion
3956162881

push

github

Michael Howitz
Update to deprecation warning free releases.

4401 of 7036 branches covered (62.55%)

Branch coverage included in aggregate %.

27161 of 31488 relevant lines covered (86.26%)

0.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.61
/src/OFS/Uninstalled.py
1
##############################################################################
2
#
3
# Copyright (c) 2002 Zope Foundation and Contributors.
4
#
5
# This software is subject to the provisions of the Zope Public License,
6
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
7
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
8
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
9
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
10
# FOR A PARTICULAR PURPOSE
11
#
12
##############################################################################
13
"""
1✔
14
Objects for packages that have been uninstalled.
15
"""
16
import html
1✔
17
from _thread import allocate_lock
1✔
18
from logging import getLogger
1✔
19

20
from Acquisition import Acquired
1✔
21
from Acquisition import Explicit
1✔
22
from App.special_dtml import DTMLFile
1✔
23
from OFS.SimpleItem import Item
1✔
24
from Persistence import Overridable
1✔
25
from ZODB.broken import Broken as ZODB_Broken
1✔
26
from ZODB.broken import persistentBroken
1✔
27

28

29
broken_klasses = {}
1✔
30
broken_klasses_lock = allocate_lock()
1✔
31
LOG = getLogger('OFS.Uninstalled')
1✔
32

33

34
class BrokenClass(ZODB_Broken, Explicit, Item, Overridable):
1✔
35
    _p_changed = 0
1✔
36
    meta_type = 'Broken Because Product is Gone'
1✔
37

38
    product_name = 'unknown'
1✔
39
    id = 'broken'
1✔
40

41
    manage_page_header = Acquired
1✔
42
    manage_page_footer = Acquired
1✔
43

44
    def __getattr__(self, name):
1✔
45
        if name[:3] == '_p_':
1!
46
            return BrokenClass.inheritedAttribute('__getattr__')(self, name)
×
47
        raise AttributeError(html.escape(name, True))
1✔
48

49
    manage = DTMLFile('dtml/brokenEdit', globals())
1✔
50
    manage_main = DTMLFile('dtml/brokenEdit', globals())
1✔
51
    manage_workspace = DTMLFile('dtml/brokenEdit', globals())
1✔
52

53

54
def Broken(self, oid, pair):
1✔
55
    broken_klasses_lock.acquire()
1✔
56
    try:
1✔
57
        if pair in broken_klasses:
1✔
58
            klass = broken_klasses[pair]
1✔
59
        else:
60
            module, klassname = pair
1✔
61
            d = {'BrokenClass': BrokenClass}
1✔
62
            exec("class %s(BrokenClass): ' '; __module__=%r" %
1✔
63
                 (klassname, module), d)
64
            klass = broken_klasses[pair] = d[klassname]
1✔
65
            module = module.split('.')
1✔
66
            if len(module) > 2 and module[0] == 'Products':
1✔
67
                klass.product_name = module[1]
1✔
68
            klass.title = (
1✔
69
                'This object from the %s product '
70
                'is broken!' %
71
                klass.product_name)
72
            klass.info = (
1✔
73
                'This object\'s class was %s in module %s.' %
74
                (klass.__name__, klass.__module__))
75
            klass = persistentBroken(klass)
1✔
76
            LOG.warning(
1✔
77
                'Could not import class %r '
78
                'from module %r' % (klass.__name__, klass.__module__))
79
    finally:
80
        broken_klasses_lock.release()
1✔
81
    if oid is None:
1✔
82
        return klass
1✔
83
    i = klass()
1✔
84
    i._p_oid = oid
1✔
85
    i._p_jar = self
1✔
86
    return i
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc