Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
9713f0a2
Commit
9713f0a2
authored
Jun 27, 2010
by
Godefroid Chapelle
Browse files
Options
Browse Files
Download
Plain Diff
merge branch gotcha-processlifetime
notify IDatabaseOpenedWithRoot test also for IDatabaseOpened
parents
59cedb99
aa3f3a07
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
2 deletions
+69
-2
doc/CHANGES.rst
doc/CHANGES.rst
+2
-0
src/Zope2/App/startup.py
src/Zope2/App/startup.py
+4
-2
src/Zope2/App/tests/test_startup.py
src/Zope2/App/tests/test_startup.py
+63
-0
No files found.
doc/CHANGES.rst
View file @
9713f0a2
...
...
@@ -18,6 +18,8 @@ Bugs Fixed
Features Added
++++++++++++++
- Added notification of IDatabaseOpenedWithRoot.
- Added a new API's ``get_registered_packages, set_registered_packages`` to
``OFS.metaconfigure`` which replace any direct access to
``Products._registered_packages``.
...
...
src/Zope2/App/startup.py
View file @
9713f0a2
...
...
@@ -16,6 +16,7 @@
from
zope.component
import
queryMultiAdapter
from
zope.event
import
notify
from
zope.processlifetime
import
DatabaseOpened
from
zope.processlifetime
import
DatabaseOpenedWithRoot
from
AccessControl.SecurityManagement
import
newSecurityManager
from
AccessControl.SecurityManagement
import
noSecurityManager
...
...
@@ -134,6 +135,8 @@ def startup():
global
startup_time
startup_time
=
asctime
()
notify
(
DatabaseOpenedWithRoot
(
DB
))
Zope2
.
zpublisher_transactions_manager
=
TransactionsManager
()
Zope2
.
zpublisher_exception_hook
=
zpublisher_exception_hook
Zope2
.
zpublisher_validated_hook
=
validated_hook
...
...
@@ -206,7 +209,7 @@ class ZPublisherExceptionHook:
else
:
error_log_url
=
log
.
raising
((
t
,
v
,
traceback
))
if
(
REQUEST
is
None
or
if
(
REQUEST
is
None
or
(
getattr
(
REQUEST
.
get
(
'RESPONSE'
,
None
),
'_error_format'
,
''
)
!=
'text/html'
)):
raise
t
,
v
,
traceback
...
...
@@ -277,7 +280,6 @@ class ZPublisherExceptionHook:
response
.
setStatus
(
t
)
response
.
setBody
(
v
)
return
response
finally
:
traceback
=
None
...
...
src/Zope2/App/tests/test_startup.py
0 → 100644
View file @
9713f0a2
##############################################################################
#
# Copyright (c) 2010 Zope Foundation and Contributors.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
import
logging
from
Testing.ZopeTestCase
import
ZopeTestCase
from
zope.testing.loggingsupport
import
InstalledHandler
logged
=
"""Zope2.App.test_startup INFO
<class 'zope.processlifetime.DatabaseOpened'>
Zope2.App.test_startup INFO
<class 'ZODB.DB.DB'>
Zope2.App.test_startup INFO
Root not ready.
Zope2.App.test_startup INFO
<class 'zope.processlifetime.DatabaseOpenedWithRoot'>
Zope2.App.test_startup INFO
<class 'ZODB.DB.DB'>
Zope2.App.test_startup INFO
<class 'OFS.Application.Application'>"""
def
logevent
(
event
):
logger
=
logging
.
getLogger
(
'Zope2.App.test_startup'
)
logger
.
info
(
event
.
__class__
)
db
=
event
.
database
logger
.
info
(
db
.
__class__
)
conn
=
db
.
open
()
try
:
try
:
root
=
conn
.
root
()
app
=
root
[
'Application'
]
logger
.
info
(
app
.
__class__
)
except
KeyError
:
logger
.
info
(
'Root not ready.'
)
finally
:
conn
.
close
()
class
StartupTests
(
ZopeTestCase
):
def
test_dummy
(
self
):
from
Zope2.App.startup
import
startup
from
zope.component
import
provideHandler
from
zope.processlifetime
import
IDatabaseOpened
from
zope.processlifetime
import
IDatabaseOpenedWithRoot
handler
=
InstalledHandler
(
'Zope2.App.test_startup'
)
provideHandler
(
logevent
,
[
IDatabaseOpenedWithRoot
])
provideHandler
(
logevent
,
[
IDatabaseOpened
])
startup
()
self
.
assertEqual
(
str
(
handler
),
logged
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment