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
33f72dcb
Commit
33f72dcb
authored
Aug 07, 2016
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
flake8
parent
b625d776
Changes
17
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
94 additions
and
97 deletions
+94
-97
src/Zope2/App/ClassFactory.py
src/Zope2/App/ClassFactory.py
+6
-8
src/Zope2/App/__init__.py
src/Zope2/App/__init__.py
+0
-13
src/Zope2/App/startup.py
src/Zope2/App/startup.py
+20
-18
src/Zope2/App/tests/__init__.py
src/Zope2/App/tests/__init__.py
+0
-15
src/Zope2/App/tests/testDoomedTransaction.py
src/Zope2/App/tests/testDoomedTransaction.py
+1
-5
src/Zope2/App/tests/testExceptionHook.py
src/Zope2/App/tests/testExceptionHook.py
+31
-12
src/Zope2/App/tests/test_schema.py
src/Zope2/App/tests/test_schema.py
+1
-0
src/Zope2/App/traversing.py
src/Zope2/App/traversing.py
+13
-0
src/Zope2/App/zcml.py
src/Zope2/App/zcml.py
+1
-3
src/Zope2/ClassFactory.py
src/Zope2/ClassFactory.py
+7
-4
src/Zope2/Startup/httpexceptions.py
src/Zope2/Startup/httpexceptions.py
+14
-0
src/Zope2/Startup/tests/__init__.py
src/Zope2/Startup/tests/__init__.py
+0
-15
src/Zope2/Startup/tests/test_schema.py
src/Zope2/Startup/tests/test_schema.py
+0
-1
src/Zope2/Startup/tests/test_starter.py
src/Zope2/Startup/tests/test_starter.py
+0
-0
src/Zope2/Startup/tests/test_warnfilter.py
src/Zope2/Startup/tests/test_warnfilter.py
+0
-1
src/Zope2/Startup/zopectl.py
src/Zope2/Startup/zopectl.py
+0
-1
src/Zope2/utilities/__init__.py
src/Zope2/utilities/__init__.py
+0
-1
No files found.
src/Zope2/App/ClassFactory.py
View file @
33f72dcb
...
@@ -10,15 +10,13 @@
...
@@ -10,15 +10,13 @@
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Zope Framework Class Finder
"""
import
OFS.Uninstalled
import
OFS.Uninstalled
def
ClassFactory
(
jar
,
module
,
name
,
_silly
=
(
'__doc__'
,),
_globals
=
{},
def
ClassFactory
(
jar
,
module
,
name
,
_silly
=
(
'__doc__'
,),
_globals
=
{}):
):
try
:
try
:
m
=
__import__
(
module
,
_globals
,
_globals
,
_silly
)
m
=
__import__
(
module
,
_globals
,
_globals
,
_silly
)
return
getattr
(
m
,
name
)
return
getattr
(
m
,
name
)
except
:
except
:
return
OFS
.
Uninstalled
.
Broken
(
jar
,
None
,
(
module
,
name
))
return
OFS
.
Uninstalled
.
Broken
(
jar
,
None
,
(
module
,
name
))
src/Zope2/App/__init__.py
View file @
33f72dcb
##############################################################################
#
# Copyright (c) 2002 Zope Foundation and Contributors.
# All Rights Reserved.
#
# 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.
#
##############################################################################
src/Zope2/App/startup.py
View file @
33f72dcb
...
@@ -84,21 +84,21 @@ def startup():
...
@@ -84,21 +84,21 @@ def startup():
try
:
try
:
# Try to use custom storage
# Try to use custom storage
try
:
try
:
m
=
imp
.
find_module
(
'custom_zodb'
,
[
configuration
.
testinghome
])
m
=
imp
.
find_module
(
'custom_zodb'
,
[
configuration
.
testinghome
])
except
:
except
:
m
=
imp
.
find_module
(
'custom_zodb'
,
[
configuration
.
instancehome
])
m
=
imp
.
find_module
(
'custom_zodb'
,
[
configuration
.
instancehome
])
except
Exception
:
except
Exception
:
# if there is no custom_zodb, use the config file specified databases
# if there is no custom_zodb, use the config file specified databases
DB
=
dbtab
.
getDatabase
(
'/'
,
is_root
=
1
)
DB
=
dbtab
.
getDatabase
(
'/'
,
is_root
=
1
)
else
:
else
:
m
=
imp
.
load_module
(
'Zope2.custom_zodb'
,
m
[
0
],
m
[
1
],
m
[
2
])
m
=
imp
.
load_module
(
'Zope2.custom_zodb'
,
m
[
0
],
m
[
1
],
m
[
2
])
sys
.
modules
[
'Zope2.custom_zodb'
]
=
m
sys
.
modules
[
'Zope2.custom_zodb'
]
=
m
# Get the database and join it to the dbtab multidatabase
# Get the database and join it to the dbtab multidatabase
# FIXME: this uses internal datastructures of dbtab
# FIXME: this uses internal datastructures of dbtab
databases
=
getattr
(
dbtab
,
'databases'
,
{})
databases
=
getattr
(
dbtab
,
'databases'
,
{})
if
hasattr
(
m
,
'DB'
):
if
hasattr
(
m
,
'DB'
):
DB
=
m
.
DB
DB
=
m
.
DB
databases
.
update
(
getattr
(
DB
,
'databases'
,
{}))
databases
.
update
(
getattr
(
DB
,
'databases'
,
{}))
DB
.
databases
=
databases
DB
.
databases
=
databases
else
:
else
:
...
@@ -173,7 +173,7 @@ def validated_hook(request, user):
...
@@ -173,7 +173,7 @@ def validated_hook(request, user):
class
RequestContainer
(
ExtensionClass
.
Base
):
class
RequestContainer
(
ExtensionClass
.
Base
):
def
__init__
(
self
,
r
):
def
__init__
(
self
,
r
):
self
.
REQUEST
=
r
self
.
REQUEST
=
r
class
ZPublisherExceptionHook
:
class
ZPublisherExceptionHook
:
...
@@ -234,8 +234,8 @@ class ZPublisherExceptionHook:
...
@@ -234,8 +234,8 @@ class ZPublisherExceptionHook:
error_log_url
=
log
.
raising
((
t
,
v
,
traceback
))
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'
,
''
)
(
getattr
(
REQUEST
.
get
(
'RESPONSE'
,
None
),
!=
'text/html'
)):
'_error_format'
,
''
)
!=
'text/html'
)):
raise
t
,
v
,
traceback
raise
t
,
v
,
traceback
# Lookup a view for the exception and render it, then
# Lookup a view for the exception and render it, then
...
@@ -245,7 +245,8 @@ class ZPublisherExceptionHook:
...
@@ -245,7 +245,8 @@ class ZPublisherExceptionHook:
# zope.publisher uses as well.
# zope.publisher uses as well.
view
=
queryMultiAdapter
((
v
,
REQUEST
),
name
=
u'index.html'
)
view
=
queryMultiAdapter
((
v
,
REQUEST
),
name
=
u'index.html'
)
if
view
is
not
None
:
if
view
is
not
None
:
if
IAcquirer
.
providedBy
(
view
)
and
IAcquirer
.
providedBy
(
published
):
if
(
IAcquirer
.
providedBy
(
view
)
and
IAcquirer
.
providedBy
(
published
)):
view
=
view
.
__of__
(
published
)
view
=
view
.
__of__
(
published
)
else
:
else
:
view
.
__parent__
=
published
view
.
__parent__
=
published
...
@@ -264,7 +265,7 @@ class ZPublisherExceptionHook:
...
@@ -264,7 +265,7 @@ class ZPublisherExceptionHook:
if
(
published
is
None
or
published
is
app
or
if
(
published
is
None
or
published
is
app
or
isinstance
(
published
,
list
)):
isinstance
(
published
,
list
)):
# At least get the top-level object
# At least get the top-level object
published
=
app
.
__bobo_traverse__
(
REQUEST
).
__of__
(
published
=
app
.
__bobo_traverse__
(
REQUEST
).
__of__
(
RequestContainer
(
REQUEST
))
RequestContainer
(
REQUEST
))
published
=
getattr
(
published
,
'im_self'
,
published
)
published
=
getattr
(
published
,
'im_self'
,
published
)
...
@@ -312,7 +313,9 @@ class ZPublisherExceptionHook:
...
@@ -312,7 +313,9 @@ class ZPublisherExceptionHook:
zpublisher_exception_hook
=
ZPublisherExceptionHook
()
zpublisher_exception_hook
=
ZPublisherExceptionHook
()
ac_logger
=
logging
.
getLogger
(
'event.AccessControl'
)
ac_logger
=
logging
.
getLogger
(
'event.AccessControl'
)
class
TransactionsManager
:
class
TransactionsManager
(
object
):
def
begin
(
self
,
def
begin
(
self
,
# Optimize global var lookups:
# Optimize global var lookups:
transaction
=
transaction
):
transaction
=
transaction
):
...
@@ -345,8 +348,8 @@ class TransactionsManager:
...
@@ -345,8 +348,8 @@ class TransactionsManager:
to_append
=
(
object
.
__name__
,)
to_append
=
(
object
.
__name__
,)
object
=
object
.
im_self
object
=
object
.
im_self
while
object
is
not
None
and
\
while
(
object
is
not
None
and
not
hasattr
(
object
,
'getPhysicalPath'
):
not
hasattr
(
object
,
'getPhysicalPath'
)
):
if
getattr
(
object
,
'__name__'
,
None
)
is
None
:
if
getattr
(
object
,
'__name__'
,
None
)
is
None
:
object
=
None
object
=
None
break
break
...
@@ -364,14 +367,13 @@ class TransactionsManager:
...
@@ -364,14 +367,13 @@ class TransactionsManager:
T
=
transaction
.
get
()
T
=
transaction
.
get
()
T
.
note
(
path
)
T
.
note
(
path
)
auth_user
=
request_get
(
'AUTHENTICATED_USER'
,
None
)
auth_user
=
request_get
(
'AUTHENTICATED_USER'
,
None
)
if
auth_user
is
not
None
:
if
auth_user
is
not
None
:
auth_folder
=
aq_parent
(
auth_user
)
auth_folder
=
aq_parent
(
auth_user
)
if
auth_folder
is
None
:
if
auth_folder
is
None
:
ac_logger
.
warning
(
ac_logger
.
warning
(
'A user object of type %s has no aq_parent.'
,
'A user object of type %s has no aq_parent.'
,
type
(
auth_user
)
type
(
auth_user
))
)
auth_path
=
request_get
(
'AUTHENTICATION_PATH'
)
auth_path
=
request_get
(
'AUTHENTICATION_PATH'
)
else
:
else
:
auth_path
=
'/'
.
join
(
auth_folder
.
getPhysicalPath
()[
1
:
-
1
])
auth_path
=
'/'
.
join
(
auth_folder
.
getPhysicalPath
()[
1
:
-
1
])
...
...
src/Zope2/App/tests/__init__.py
View file @
33f72dcb
##############################################################################
#
# Copyright (c) 2007 Zope Foundation and Contributors.
# All Rights Reserved.
#
# 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.
#
##############################################################################
"""Tests of the Zope2.App package."""
src/Zope2/App/tests/testDoomedTransaction.py
View file @
33f72dcb
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
import
unittest
import
unittest
import
transaction
import
transaction
class
DoomedTransactionInManagerTest
(
unittest
.
TestCase
):
class
DoomedTransactionInManagerTest
(
unittest
.
TestCase
):
def
testDoomedFails
(
self
):
def
testDoomedFails
(
self
):
...
@@ -31,8 +32,3 @@ class DoomedTransactionInManagerTest(unittest.TestCase):
...
@@ -31,8 +32,3 @@ class DoomedTransactionInManagerTest(unittest.TestCase):
trans
=
transaction
.
get
()
trans
=
transaction
.
get
()
trans
.
doom
()
trans
.
doom
()
tm
.
commit
()
tm
.
commit
()
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
DoomedTransactionInManagerTest
))
return
suite
src/Zope2/App/tests/testExceptionHook.py
View file @
33f72dcb
...
@@ -110,9 +110,10 @@ class ExceptionHookTestCase(unittest.TestCase):
...
@@ -110,9 +110,10 @@ class ExceptionHookTestCase(unittest.TestCase):
sys
.
exc_info
()[
1
],
sys
.
exc_info
()[
1
],
sys
.
exc_info
()[
2
],
sys
.
exc_info
()[
2
],
)
)
except
Exception
,
e
:
except
Exception
as
e
:
return
e
return
e
class
ExceptionHookTest
(
ExceptionHookTestCase
):
class
ExceptionHookTest
(
ExceptionHookTestCase
):
def
testSystemExit
(
self
):
def
testSystemExit
(
self
):
...
@@ -122,6 +123,7 @@ class ExceptionHookTest(ExceptionHookTestCase):
...
@@ -122,6 +123,7 @@ class ExceptionHookTest(ExceptionHookTestCase):
def
testUnauthorized
(
self
):
def
testUnauthorized
(
self
):
from
AccessControl
import
Unauthorized
from
AccessControl
import
Unauthorized
def
f
():
def
f
():
raise
Unauthorized
(
'1'
)
raise
Unauthorized
(
'1'
)
self
.
assertRaises
(
Unauthorized
,
self
.
call
,
None
,
{},
f
)
self
.
assertRaises
(
Unauthorized
,
self
.
call
,
None
,
{},
f
)
...
@@ -130,6 +132,7 @@ class ExceptionHookTest(ExceptionHookTestCase):
...
@@ -130,6 +132,7 @@ class ExceptionHookTest(ExceptionHookTestCase):
from
ZPublisher
import
Retry
from
ZPublisher
import
Retry
from
ZODB.POSException
import
ConflictError
from
ZODB.POSException
import
ConflictError
from
App.config
import
getConfiguration
from
App.config
import
getConfiguration
def
f
():
def
f
():
raise
ConflictError
()
raise
ConflictError
()
request
=
self
.
_makeRequest
()
request
=
self
.
_makeRequest
()
...
@@ -145,6 +148,7 @@ class ExceptionHookTest(ExceptionHookTestCase):
...
@@ -145,6 +148,7 @@ class ExceptionHookTest(ExceptionHookTestCase):
def
testConflictErrorCount
(
self
):
def
testConflictErrorCount
(
self
):
from
ZODB.POSException
import
ConflictError
from
ZODB.POSException
import
ConflictError
def
f
():
def
f
():
raise
ConflictError
()
raise
ConflictError
()
hook
=
self
.
_makeOne
()
hook
=
self
.
_makeOne
()
...
@@ -156,8 +160,10 @@ class ExceptionHookTest(ExceptionHookTestCase):
...
@@ -156,8 +160,10 @@ class ExceptionHookTest(ExceptionHookTestCase):
def
testRetryRaisesOriginalException
(
self
):
def
testRetryRaisesOriginalException
(
self
):
from
ZPublisher
import
Retry
from
ZPublisher
import
Retry
class
CustomException
(
Exception
):
class
CustomException
(
Exception
):
pass
pass
def
f
():
def
f
():
try
:
try
:
raise
CustomException
(
'Zope'
)
raise
CustomException
(
'Zope'
)
...
@@ -170,6 +176,7 @@ class ExceptionHookTest(ExceptionHookTestCase):
...
@@ -170,6 +176,7 @@ class ExceptionHookTest(ExceptionHookTestCase):
def
testRetryRaisesConflictError
(
self
):
def
testRetryRaisesConflictError
(
self
):
from
ZPublisher
import
Retry
from
ZPublisher
import
Retry
from
ZODB.POSException
import
ConflictError
from
ZODB.POSException
import
ConflictError
def
f
():
def
f
():
try
:
try
:
raise
ConflictError
()
raise
ConflictError
()
...
@@ -182,6 +189,7 @@ class ExceptionHookTest(ExceptionHookTestCase):
...
@@ -182,6 +189,7 @@ class ExceptionHookTest(ExceptionHookTestCase):
def
testRetryUnresolvedConflictErrorCount
(
self
):
def
testRetryUnresolvedConflictErrorCount
(
self
):
from
ZPublisher
import
Retry
from
ZPublisher
import
Retry
from
ZODB.POSException
import
ConflictError
from
ZODB.POSException
import
ConflictError
def
f
():
def
f
():
try
:
try
:
raise
ConflictError
()
raise
ConflictError
()
...
@@ -196,6 +204,7 @@ class ExceptionHookTest(ExceptionHookTestCase):
...
@@ -196,6 +204,7 @@ class ExceptionHookTest(ExceptionHookTestCase):
self
.
call_no_exc
(
hook
,
None
,
None
,
f
)
self
.
call_no_exc
(
hook
,
None
,
None
,
f
)
self
.
assertEquals
(
hook
.
unresolved_conflict_errors
,
2
)
self
.
assertEquals
(
hook
.
unresolved_conflict_errors
,
2
)
class
Client
(
Acquisition
.
Explicit
):
class
Client
(
Acquisition
.
Explicit
):
def
__init__
(
self
):
def
__init__
(
self
):
...
@@ -205,6 +214,7 @@ class Client(Acquisition.Explicit):
...
@@ -205,6 +214,7 @@ class Client(Acquisition.Explicit):
def
dummyMethod
(
self
):
def
dummyMethod
(
self
):
return
'Aye'
return
'Aye'
class
StandardClient
(
Client
):
class
StandardClient
(
Client
):
def
raise_standardErrorMessage
(
self
,
c
,
r
,
t
,
v
,
tb
,
error_log_url
):
def
raise_standardErrorMessage
(
self
,
c
,
r
,
t
,
v
,
tb
,
error_log_url
):
...
@@ -212,15 +222,18 @@ class StandardClient(Client):
...
@@ -212,15 +222,18 @@ class StandardClient(Client):
fmt
=
format_exception
(
t
,
v
,
tb
,
as_html
=
0
)
fmt
=
format_exception
(
t
,
v
,
tb
,
as_html
=
0
)
self
.
messages
.
append
(
''
.
join
([
error_log_url
]
+
fmt
))
self
.
messages
.
append
(
''
.
join
([
error_log_url
]
+
fmt
))
class
BrokenClient
(
Client
):
class
BrokenClient
(
Client
):
def
raise_standardErrorMessage
(
self
,
c
,
r
,
t
,
v
,
tb
,
error_log_url
):
def
raise_standardErrorMessage
(
self
,
c
,
r
,
t
,
v
,
tb
,
error_log_url
):
raise
AttributeError
(
'ouch'
)
raise
AttributeError
(
'ouch'
)
class
ExceptionMessageRenderTest
(
ExceptionHookTestCase
):
class
ExceptionMessageRenderTest
(
ExceptionHookTestCase
):
def
testRenderUnauthorizedStandardClient
(
self
):
def
testRenderUnauthorizedStandardClient
(
self
):
from
AccessControl
import
Unauthorized
from
AccessControl
import
Unauthorized
def
f
():
def
f
():
raise
Unauthorized
(
'1'
)
raise
Unauthorized
(
'1'
)
request
=
self
.
_makeRequest
()
request
=
self
.
_makeRequest
()
...
@@ -232,6 +245,7 @@ class ExceptionMessageRenderTest(ExceptionHookTestCase):
...
@@ -232,6 +245,7 @@ class ExceptionMessageRenderTest(ExceptionHookTestCase):
def
testRenderUnauthorizedStandardClientMethod
(
self
):
def
testRenderUnauthorizedStandardClientMethod
(
self
):
from
AccessControl
import
Unauthorized
from
AccessControl
import
Unauthorized
def
f
():
def
f
():
raise
Unauthorized
(
'1'
)
raise
Unauthorized
(
'1'
)
request
=
self
.
_makeRequest
()
request
=
self
.
_makeRequest
()
...
@@ -243,6 +257,7 @@ class ExceptionMessageRenderTest(ExceptionHookTestCase):
...
@@ -243,6 +257,7 @@ class ExceptionMessageRenderTest(ExceptionHookTestCase):
def
testRenderUnauthorizedBrokenClient
(
self
):
def
testRenderUnauthorizedBrokenClient
(
self
):
from
AccessControl
import
Unauthorized
from
AccessControl
import
Unauthorized
def
f
():
def
f
():
raise
Unauthorized
(
'1'
)
raise
Unauthorized
(
'1'
)
request
=
self
.
_makeRequest
()
request
=
self
.
_makeRequest
()
...
@@ -251,8 +266,10 @@ class ExceptionMessageRenderTest(ExceptionHookTestCase):
...
@@ -251,8 +266,10 @@ class ExceptionMessageRenderTest(ExceptionHookTestCase):
def
testRenderRetryRaisesOriginalException
(
self
):
def
testRenderRetryRaisesOriginalException
(
self
):
from
ZPublisher
import
Retry
from
ZPublisher
import
Retry
class
CustomException
(
Exception
):
class
CustomException
(
Exception
):
pass
pass
def
f
():
def
f
():
try
:
try
:
raise
CustomException
(
'Zope'
)
raise
CustomException
(
'Zope'
)
...
@@ -270,6 +287,7 @@ class ExceptionMessageRenderTest(ExceptionHookTestCase):
...
@@ -270,6 +287,7 @@ class ExceptionMessageRenderTest(ExceptionHookTestCase):
def
testRenderRetryRaisesConflictError
(
self
):
def
testRenderRetryRaisesConflictError
(
self
):
from
ZPublisher
import
Retry
from
ZPublisher
import
Retry
from
ZODB.POSException
import
ConflictError
from
ZODB.POSException
import
ConflictError
def
f
():
def
f
():
try
:
try
:
raise
ConflictError
()
raise
ConflictError
()
...
@@ -284,6 +302,7 @@ class ExceptionMessageRenderTest(ExceptionHookTestCase):
...
@@ -284,6 +302,7 @@ class ExceptionMessageRenderTest(ExceptionHookTestCase):
tb
=
client
.
messages
[
0
]
tb
=
client
.
messages
[
0
]
self
.
assertTrue
(
"ConflictError: database conflict error"
in
tb
,
tb
)
self
.
assertTrue
(
"ConflictError: database conflict error"
in
tb
,
tb
)
class
CustomExceptionView
(
Acquisition
.
Explicit
):
class
CustomExceptionView
(
Acquisition
.
Explicit
):
def
__init__
(
self
,
context
,
request
):
def
__init__
(
self
,
context
,
request
):
...
@@ -291,9 +310,10 @@ class CustomExceptionView(Acquisition.Explicit):
...
@@ -291,9 +310,10 @@ class CustomExceptionView(Acquisition.Explicit):
self
.
request
=
request
self
.
request
=
request
def
__call__
(
self
):
def
__call__
(
self
):
return
"Exception View: %s
\
n
Context: %s"
%
(
return
(
"Exception View: %s
\
n
Context: %s"
%
(
self
.
context
.
__class__
.
__name__
,
self
.
context
.
__class__
.
__name__
,
Acquisition
.
aq_parent
(
self
).
__class__
.
__name__
)
Acquisition
.
aq_parent
(
self
).
__class__
.
__name__
))
def
registerExceptionView
(
for_
):
def
registerExceptionView
(
for_
):
from
zope.interface
import
Interface
from
zope.interface
import
Interface
...
@@ -307,11 +327,13 @@ def registerExceptionView(for_):
...
@@ -307,11 +327,13 @@ def registerExceptionView(for_):
name
=
u'index.html'
,
name
=
u'index.html'
,
)
)
class
ExceptionViewsTest
(
PlacelessSetup
,
ExceptionHookTestCase
):
class
ExceptionViewsTest
(
PlacelessSetup
,
ExceptionHookTestCase
):
def
testCustomExceptionViewUnauthorized
(
self
):
def
testCustomExceptionViewUnauthorized
(
self
):
from
AccessControl
import
Unauthorized
from
AccessControl
import
Unauthorized
registerExceptionView
(
IUnauthorized
)
registerExceptionView
(
IUnauthorized
)
def
f
():
def
f
():
raise
Unauthorized
(
'1'
)
raise
Unauthorized
(
'1'
)
request
=
self
.
_makeRequest
()
request
=
self
.
_makeRequest
()
...
@@ -325,6 +347,7 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
...
@@ -325,6 +347,7 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
from
ZPublisher.HTTPResponse
import
HTTPResponse
from
ZPublisher.HTTPResponse
import
HTTPResponse
from
zExceptions
import
Forbidden
from
zExceptions
import
Forbidden
registerExceptionView
(
IForbidden
)
registerExceptionView
(
IForbidden
)
def
f
():
def
f
():
raise
Forbidden
(
"argh"
)
raise
Forbidden
(
"argh"
)
request
=
self
.
_makeRequest
()
request
=
self
.
_makeRequest
()
...
@@ -338,6 +361,7 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
...
@@ -338,6 +361,7 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
from
ZPublisher.HTTPResponse
import
HTTPResponse
from
ZPublisher.HTTPResponse
import
HTTPResponse
from
zExceptions
import
NotFound
from
zExceptions
import
NotFound
registerExceptionView
(
INotFound
)
registerExceptionView
(
INotFound
)
def
f
():
def
f
():
raise
NotFound
(
"argh"
)
raise
NotFound
(
"argh"
)
request
=
self
.
_makeRequest
()
request
=
self
.
_makeRequest
()
...
@@ -351,6 +375,7 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
...
@@ -351,6 +375,7 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
from
ZPublisher.HTTPResponse
import
HTTPResponse
from
ZPublisher.HTTPResponse
import
HTTPResponse
from
zExceptions
import
BadRequest
from
zExceptions
import
BadRequest
registerExceptionView
(
IException
)
registerExceptionView
(
IException
)
def
f
():
def
f
():
raise
BadRequest
(
"argh"
)
raise
BadRequest
(
"argh"
)
request
=
self
.
_makeRequest
()
request
=
self
.
_makeRequest
()
...
@@ -364,6 +389,7 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
...
@@ -364,6 +389,7 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
from
ZPublisher.HTTPResponse
import
HTTPResponse
from
ZPublisher.HTTPResponse
import
HTTPResponse
from
zExceptions
import
InternalError
from
zExceptions
import
InternalError
registerExceptionView
(
IException
)
registerExceptionView
(
IException
)
def
f
():
def
f
():
raise
InternalError
(
"argh"
)
raise
InternalError
(
"argh"
)
request
=
self
.
_makeRequest
()
request
=
self
.
_makeRequest
()
...
@@ -376,6 +402,7 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
...
@@ -376,6 +402,7 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
def
testRedirectNoExceptionView
(
self
):
def
testRedirectNoExceptionView
(
self
):
from
zExceptions
import
Redirect
from
zExceptions
import
Redirect
registerExceptionView
(
IException
)
registerExceptionView
(
IException
)
def
f
():
def
f
():
raise
Redirect
(
"http://zope.org/"
)
raise
Redirect
(
"http://zope.org/"
)
request
=
self
.
_makeRequest
()
request
=
self
.
_makeRequest
()
...
@@ -383,11 +410,3 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
...
@@ -383,11 +410,3 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
v
=
self
.
call_exc_value
(
client
,
request
,
f
)
v
=
self
.
call_exc_value
(
client
,
request
,
f
)
self
.
assertTrue
(
isinstance
(
v
,
Redirect
),
v
)
self
.
assertTrue
(
isinstance
(
v
,
Redirect
),
v
)
self
.
assertEquals
(
v
.
args
[
0
],
"http://zope.org/"
)
self
.
assertEquals
(
v
.
args
[
0
],
"http://zope.org/"
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
ExceptionHookTest
))
suite
.
addTest
(
unittest
.
makeSuite
(
ExceptionMessageRenderTest
))
suite
.
addTest
(
unittest
.
makeSuite
(
ExceptionViewsTest
))
return
suite
src/Zope2/App/tests/test_schema.py
View file @
33f72dcb
...
@@ -43,6 +43,7 @@ class Zope2VocabularyRegistryTests(unittest.TestCase, CleanUp):
...
@@ -43,6 +43,7 @@ class Zope2VocabularyRegistryTests(unittest.TestCase, CleanUp):
from
zope.component
import
provideUtility
from
zope.component
import
provideUtility
from
zope.schema.interfaces
import
IVocabularyFactory
from
zope.schema.interfaces
import
IVocabularyFactory
_marker
=
object
()
_marker
=
object
()
def
_factory
(
context
):
def
_factory
(
context
):
return
_marker
return
_marker
provideUtility
(
_factory
,
IVocabularyFactory
,
'foundit'
)
provideUtility
(
_factory
,
IVocabularyFactory
,
'foundit'
)
...
...
src/Zope2/App/traversing.py
View file @
33f72dcb
##############################################################################
#
# Copyright (c) 2002 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.
#
##############################################################################
from
zExceptions
import
Forbidden
from
zExceptions
import
Forbidden
from
zope.interface.interface
import
InterfaceClass
from
zope.interface.interface
import
InterfaceClass
from
zope.traversing
import
namespace
from
zope.traversing
import
namespace
...
...
src/Zope2/App/zcml.py
View file @
33f72dcb
...
@@ -11,8 +11,6 @@
...
@@ -11,8 +11,6 @@
# FOR A PARTICULAR PURPOSE.
# FOR A PARTICULAR PURPOSE.
#
#
##############################################################################
##############################################################################
"""ZCML machinery
"""
import
os.path
import
os.path
...
@@ -70,6 +68,6 @@ def cleanUp():
...
@@ -70,6 +68,6 @@ def cleanUp():
_context
=
None
_context
=
None
from
zope.testing.cleanup
import
addCleanUp
from
zope.testing.cleanup
import
addCleanUp
# NOQA
addCleanUp
(
cleanUp
)
addCleanUp
(
cleanUp
)
del
addCleanUp
del
addCleanUp
src/Zope2/ClassFactory.py
View file @
33f72dcb
...
@@ -10,8 +10,11 @@
...
@@ -10,8 +10,11 @@
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Zope Framework Class Finder
"""
# Stub in case anyone depends on this
from
zope.deferredimport
import
deprecated
from
App.ClassFactory
import
ClassFactory
# NOQA
# BBB Zope 5.0
deprecated
(
'Please import from Zope2.App.ClassFactory.'
,
ClassFactory
=
'Zope2.App.ClassFactory:ClassFactory'
,
)
src/Zope2/Startup/httpexceptions.py
View file @
33f72dcb
##############################################################################
#
# Copyright (c) 2003 Zope Foundation and Contributors.
# All Rights Reserved.
#
# 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.
#
##############################################################################
from
zExceptions
import
(
from
zExceptions
import
(
HTTPException
,
HTTPException
,
InternalError
,
InternalError
,
...
...
src/Zope2/Startup/tests/__init__.py
View file @
33f72dcb
##############################################################################
#
# Copyright (c) 2003 Zope Foundation and Contributors.
# All Rights Reserved.
#
# 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.
#
##############################################################################
"""Tests of the Zope2.Startup package."""
src/Zope2/Startup/tests/test_schema.py
View file @
33f72dcb
...
@@ -11,7 +11,6 @@
...
@@ -11,7 +11,6 @@
# FOR A PARTICULAR PURPOSE.
# FOR A PARTICULAR PURPOSE.
#
#
##############################################################################
##############################################################################
"""Test that the Zope schema can be loaded."""
import
os
import
os
import
cStringIO
import
cStringIO
...
...
src/Zope2/Startup/tests/test
S
tarter.py
→
src/Zope2/Startup/tests/test
_s
tarter.py
View file @
33f72dcb
File moved
src/Zope2/Startup/tests/test_warnfilter.py
View file @
33f72dcb
...
@@ -11,7 +11,6 @@
...
@@ -11,7 +11,6 @@
# FOR A PARTICULAR PURPOSE.
# FOR A PARTICULAR PURPOSE.
#
#
##############################################################################
##############################################################################
"""Test that the warning filter works."""
import
os
import
os
import
cStringIO
import
cStringIO
...
...
src/Zope2/Startup/zopectl.py
View file @
33f72dcb
#!python
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
...
...
src/Zope2/utilities/__init__.py
View file @
33f72dcb
#
\ No newline at end of file
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