• 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

83.33
/src/App/ZApplication.py
1
##############################################################################
2
#
3
# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
4
# All Rights Reserved.
5
#
6
# This software is subject to the provisions of the Zope Public License,
7
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
8
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
9
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
11
# FOR A PARTICULAR PURPOSE
12
#
13
##############################################################################
14
"""Implement an bobo_application object that is BoboPOS3 aware
1✔
15

16
This module provides a wrapper that causes a database connection to be created
17
and used when bobo publishes a bobo_application object.
18
"""
19

20

21
class ZApplicationWrapper:
1✔
22

23
    def __init__(self, db, name, klass=None):
1✔
24
        self._db = db
1✔
25
        self._name = name
1✔
26
        if klass is not None:
1!
27
            conn = db.open()
1✔
28
            root = conn.root()
1✔
29
            if name not in root:
1!
30
                root[name] = klass()
1✔
31
                conn.transaction_manager.commit()
1✔
32
            conn.close()
1✔
33
            self._klass = klass
1✔
34

35
    # This hack is to overcome a bug in Bobo!
36
    def __getattr__(self, name):
1✔
37
        return getattr(self._klass, name)
×
38

39
    def __call__(self, connection=None):
1✔
40
        # This is called by ZPublisher.WSGIPublisher,
41
        # as load_app calls the app object present in the module_info.
42

43
        db = self._db
1✔
44
        if connection is None:
1✔
45
            connection = db.open()
1✔
46
        elif isinstance(connection, str):
1!
47
            connection = db.open(connection)
×
48

49
        return connection.root()[self._name]
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