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

zopefoundation / Products.Sessions / 16399689495

05 Apr 2025 07:12AM UTC coverage: 94.731%. Remained the same
16399689495

push

github

dataflake
- vb [ci skip]

146 of 180 branches covered (81.11%)

Branch coverage included in aggregate %.

1526 of 1585 relevant lines covered (96.28%)

0.96 hits per line

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

89.8
/src/Products/Sessions/__init__.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
""" Session managemnt product initialization
14
"""
15

16
from .interfaces import BrowserIdManagerErr  # noqa: F401
1✔
17
from .interfaces import SessionDataManagerErr  # noqa: F401
1✔
18
from .permissions import add_browser_id_managers
1✔
19
from .permissions import add_session_data_managers
1✔
20

21

22
def commit(note):
1✔
23
    import transaction
1✔
24
    transaction.get().note(note)
1✔
25
    transaction.commit()
1✔
26

27

28
def install_browser_id_manager(app):
1✔
29
    if hasattr(app, 'browser_id_manager'):
1!
30
        return
×
31

32
    from . import BrowserIdManager
1✔
33
    bid = BrowserIdManager.BrowserIdManager(
1✔
34
        'browser_id_manager',
35
        'Browser Id Manager',
36
    )
37
    app._setObject('browser_id_manager', bid)
1✔
38
    commit('Added browser_id_manager')
1✔
39

40

41
def install_session_data_manager(app):
1✔
42
    # Ensure that a session data manager exists
43
    if hasattr(app, 'session_data_manager'):
1!
44
        return
×
45

46
    from . import SessionDataManager
1✔
47
    sdm = SessionDataManager.SessionDataManager(
1✔
48
        'session_data_manager',
49
        title='Session Data Manager',
50
        path='/temp_folder/session_data',
51
        requestName='SESSION',
52
    )
53
    app._setObject('session_data_manager', sdm)
1✔
54
    commit('Added session_data_manager')
1✔
55

56

57
def initialize(context):
1✔
58

59
    from . import BrowserIdManager
1✔
60
    from . import SessionDataManager
1✔
61

62
    context.registerClass(
1✔
63
        BrowserIdManager.BrowserIdManager,
64
        permission=add_browser_id_managers,
65
        constructors=(BrowserIdManager.constructBrowserIdManagerForm,
66
                      BrowserIdManager.constructBrowserIdManager))
67

68
    context.registerClass(
1✔
69
        SessionDataManager.SessionDataManager,
70
        permission=add_session_data_managers,
71
        constructors=(SessionDataManager.constructSessionDataManagerForm,
72
                      SessionDataManager.constructSessionDataManager))
73

74
    # do module security declarations so folks can use some of the
75
    # module-level stuff in PythonScripts
76
    #
77
    # declare on behalf of Transience too, since ModuleSecurityInfo is too
78
    # stupid for me to declare in two places without overwriting one set
79
    # with the other. :-(
80
    from AccessControl import ModuleSecurityInfo
1✔
81
    security = ModuleSecurityInfo('Products')
1✔
82
    security.declarePublic('Sessions')  # noqa: D001
1✔
83
    security.declarePublic('Transience')  # noqa: D001
1✔
84

85
    security = ModuleSecurityInfo('Products.Sessions.interfaces')
1✔
86
    security.declareObjectPublic()
1✔
87
    security.setDefaultAccess('allow')
1✔
88

89
    security = ModuleSecurityInfo('Products.Transience')
1✔
90
    security.declarePublic('MaxTransientObjectsExceeded')  # noqa: D001
1✔
91

92
    # BBB: for names which should be imported from Products.Sessions.interfaces
93
    security = ModuleSecurityInfo('Products.Sessions')
1✔
94
    security.declarePublic('BrowserIdManagerErr')  # noqa: D001
1✔
95
    security.declarePublic('SessionDataManagerErr')  # noqa: D001
1✔
96

97
    app = context.getApplication()  # new API added in Zope 4.0b5
1✔
98
    if app is not None:
1!
99
        install_browser_id_manager(app)
1✔
100
        install_session_data_manager(app)
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