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
32f93f6d
Commit
32f93f6d
authored
Jul 03, 2011
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed persistent default code like the `error_log` and `temp_folder`.
parent
064be573
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
39 additions
and
371 deletions
+39
-371
doc/CHANGES.rst
doc/CHANGES.rst
+2
-0
src/OFS/Application.py
src/OFS/Application.py
+12
-195
src/OFS/tests/testAcquisition.py
src/OFS/tests/testAcquisition.py
+1
-76
src/OFS/tests/testAppInitializer.py
src/OFS/tests/testAppInitializer.py
+0
-73
src/Products/SiteAccess/tests/testVirtualHostMonster.py
src/Products/SiteAccess/tests/testVirtualHostMonster.py
+1
-1
src/Zope2/App/startup.py
src/Zope2/App/startup.py
+5
-6
src/webdav/tests/testPUT_factory.py
src/webdav/tests/testPUT_factory.py
+18
-20
No files found.
doc/CHANGES.rst
View file @
32f93f6d
...
...
@@ -33,6 +33,8 @@ Features Added
Restructuring
+++++++++++++
- Removed persistent default code like the `error_log` and `temp_folder`.
- Removed persistent default content, including the `standard_error_message`
template.
...
...
src/OFS/Application.py
View file @
32f93f6d
This diff is collapsed.
Click to expand it.
src/OFS/tests/testAcquisition.py
View file @
32f93f6d
...
...
@@ -29,10 +29,9 @@ from AccessControl import ClassSecurityInfo
from
AccessControl.class_init
import
InitializeClass
from
AccessControl.SecurityManagement
import
newSecurityManager
from
AccessControl.SecurityManagement
import
noSecurityManager
from
AccessControl.Permissions
import
view
,
view
_management_screens
from
AccessControl.Permissions
import
view_management_screens
from
AccessControl.ImplPython
import
guarded_getattr
as
guarded_getattr_py
from
AccessControl.ImplC
import
guarded_getattr
as
guarded_getattr_c
from
Products.SiteErrorLog.SiteErrorLog
import
SiteErrorLog
class
AllowedItem
(
SimpleItem
):
...
...
@@ -56,16 +55,6 @@ class ProtectedItem(SimpleItem):
InitializeClass
(
ProtectedItem
)
class
ProtectedSiteErrorLog
(
SiteErrorLog
):
'''This differs from the base by declaring security
for the object itself.
'''
id
=
'error_log2'
security
=
ClassSecurityInfo
()
security
.
declareObjectProtected
(
view
)
InitializeClass
(
ProtectedSiteErrorLog
)
class
TestGetAttr
(
unittest
.
TestCase
):
...
...
@@ -83,7 +72,6 @@ class TestGetAttr(unittest.TestCase):
# Set up objects in the root that we want to aquire
self
.
app
.
manage_addFolder
(
'plain_folder'
)
self
.
app
.
_setObject
(
'error_log2'
,
ProtectedSiteErrorLog
())
# We also want to be able to acquire simple attributes
self
.
app
.
manage_addProperty
(
id
=
'simple_type'
,
type
=
'string'
,
value
=
'a string'
)
...
...
@@ -131,74 +119,13 @@ class TestGetAttr(unittest.TestCase):
self
.
assertEqual
(
o
,
self
.
app
.
acl_users
)
def
testAclUsersDenied
(
self
):
# XXX: Fails in 2.7.3
o
=
self
.
guarded_getattr
(
self
.
folder
.
denied
,
'acl_users'
)
self
.
assertEqual
(
o
,
self
.
app
.
acl_users
)
def
testAclUsersProtected
(
self
):
# XXX: Fails in 2.7.3 for Anonymous
o
=
self
.
guarded_getattr
(
self
.
folder
.
protected
,
'acl_users'
)
self
.
assertEqual
(
o
,
self
.
app
.
acl_users
)
# Acquire browser id manager
def
testBrowserIdManagerAllowed
(
self
):
o
=
self
.
guarded_getattr
(
self
.
folder
.
allowed
,
'browser_id_manager'
)
self
.
assertEqual
(
o
,
self
.
app
.
browser_id_manager
)
def
testBrowserIdManagerDenied
(
self
):
o
=
self
.
guarded_getattr
(
self
.
folder
.
denied
,
'browser_id_manager'
)
self
.
assertEqual
(
o
,
self
.
app
.
browser_id_manager
)
def
testBrowserIdManagerProtected
(
self
):
o
=
self
.
guarded_getattr
(
self
.
folder
.
protected
,
'browser_id_manager'
)
self
.
assertEqual
(
o
,
self
.
app
.
browser_id_manager
)
# Acquire error log
def
testErrorLogAllowed
(
self
):
o
=
self
.
guarded_getattr
(
self
.
folder
.
allowed
,
'error_log'
)
self
.
assertEqual
(
o
,
self
.
app
.
error_log
)
def
testErrorLogDenied
(
self
):
# XXX: Fails in 2.7.3
o
=
self
.
guarded_getattr
(
self
.
folder
.
denied
,
'error_log'
)
self
.
assertEqual
(
o
,
self
.
app
.
error_log
)
def
testErrorLogProtected
(
self
):
# XXX: Fails in 2.7.3 for Anonymous
o
=
self
.
guarded_getattr
(
self
.
folder
.
protected
,
'error_log'
)
self
.
assertEqual
(
o
,
self
.
app
.
error_log
)
# Now watch this: error log with object security declaration works fine!
def
testProtectedErrorLogAllowed
(
self
):
o
=
self
.
guarded_getattr
(
self
.
folder
.
allowed
,
'error_log2'
)
self
.
assertEqual
(
o
,
self
.
app
.
error_log2
)
def
testProtectedErrorLogDenied
(
self
):
o
=
self
.
guarded_getattr
(
self
.
folder
.
denied
,
'error_log2'
)
self
.
assertEqual
(
o
,
self
.
app
.
error_log2
)
def
testProtectedErrorLogProtected
(
self
):
o
=
self
.
guarded_getattr
(
self
.
folder
.
protected
,
'error_log2'
)
self
.
assertEqual
(
o
,
self
.
app
.
error_log2
)
# This appears to mean that any potential acquiree must make sure
# to declareObjectProtected(SomePermission).
# From the ZDG:
# We've seen how to make assertions on methods - but in the case of
# someObject we are not trying to access any particular method, but
# rather the object itself (to pass it to some_method). Because the
# security machinery will try to validate access to someObject, we
# need a way to let the security machinery know how to handle access
# to the object itself in addition to protecting its methods.
# IOW, acquiring an object in restricted Python now amounts to
# "passing it to some_method".
# Also test Richard Jones' use-case of acquiring a string:
def
testSimpleTypeAllowed
(
self
):
...
...
@@ -206,12 +133,10 @@ class TestGetAttr(unittest.TestCase):
self
.
assertEqual
(
o
,
'a string'
)
def
testSimpleTypeDenied
(
self
):
# XXX: Fails in 2.7.3
o
=
self
.
guarded_getattr
(
self
.
folder
.
denied
,
'simple_type'
)
self
.
assertEqual
(
o
,
'a string'
)
def
testSimpleTypeProtected
(
self
):
# XXX: Fails in 2.7.3 for Anonymous
o
=
self
.
guarded_getattr
(
self
.
folder
.
protected
,
'simple_type'
)
self
.
assertEqual
(
o
,
'a string'
)
...
...
src/OFS/tests/testAppInitializer.py
View file @
32f93f6d
...
...
@@ -14,8 +14,6 @@
import
os
,
unittest
,
tempfile
,
cStringIO
from
logging
import
getLogger
from
OFS.Application
import
Application
,
AppInitializer
import
Zope2.Startup
import
ZConfig
...
...
@@ -101,69 +99,6 @@ class TestInitialization( unittest.TestCase ):
self
.
assertTrue
(
hasattr
(
app
,
'Control_Panel'
))
self
.
assertEqual
(
app
.
Control_Panel
.
meta_type
,
'Control Panel'
)
def
test_install_tempfolder_and_sdc
(
self
):
self
.
configure
(
good_cfg
)
i
=
self
.
getOne
()
i
.
install_tempfolder_and_sdc
()
app
=
i
.
getApp
()
self
.
assertEqual
(
app
.
temp_folder
.
meta_type
,
'Temporary Folder'
)
self
.
assertEqual
(
app
.
temp_folder
.
session_data
.
meta_type
,
'Transient Object Container'
)
self
.
assertTrue
(
app
.
_getInitializerFlag
(
'temp_folder'
))
def
test_install_tempfolder_and_sdc_status
(
self
):
self
.
configure
(
good_cfg
)
i
=
self
.
getOne
()
status
=
i
.
install_tempfolder_and_sdc
()
self
.
assertTrue
(
status
)
i
=
self
.
getOne
()
self
.
configure
(
bad_cfg
)
try
:
logger
=
getLogger
(
'Zope.ZODBMountPoint'
)
logger
.
disabled
=
1
status
=
i
.
install_tempfolder_and_sdc
()
finally
:
logger
.
disabled
=
0
self
.
assertFalse
(
status
)
def
test_install_tempfolder_and_sdc_unlimited_sessions
(
self
):
unlimited_cfg
=
good_cfg
+
"""
maximum-number-of-session-objects 0
"""
self
.
configure
(
unlimited_cfg
)
i
=
self
.
getOne
()
status
=
i
.
install_tempfolder_and_sdc
()
self
.
assertTrue
(
status
)
sdc
=
i
.
getApp
().
temp_folder
.
session_data
self
.
assertEqual
(
sdc
.
getSubobjectLimit
(),
0
)
def
test_install_browser_id_manager
(
self
):
self
.
configure
(
good_cfg
)
i
=
self
.
getOne
()
app
=
i
.
getApp
()
i
.
install_browser_id_manager
()
self
.
assertEqual
(
app
.
browser_id_manager
.
meta_type
,
'Browser Id Manager'
)
self
.
assertTrue
(
app
.
_getInitializerFlag
(
'browser_id_manager'
))
def
test_install_virtual_hosting
(
self
):
self
.
configure
(
good_cfg
)
i
=
self
.
getOne
()
app
=
i
.
getApp
()
i
.
install_virtual_hosting
()
self
.
assertEqual
(
app
.
virtual_hosting
.
meta_type
,
'Virtual Host Monster'
)
self
.
assertTrue
(
app
.
_getInitializerFlag
(
'virtual_hosting'
))
def
test_install_session_data_manager
(
self
):
self
.
configure
(
good_cfg
)
i
=
self
.
getOne
()
i
.
install_session_data_manager
()
app
=
i
.
getApp
()
self
.
assertEqual
(
app
.
session_data_manager
.
meta_type
,
'Session Data Manager'
)
self
.
assertTrue
(
app
.
_getInitializerFlag
(
'session_data_manager'
))
def
test_install_required_roles
(
self
):
self
.
configure
(
good_cfg
)
i
=
self
.
getOne
()
...
...
@@ -187,14 +122,6 @@ class TestInitialization( unittest.TestCase ):
if
os
.
path
.
exists
(
fname
):
os
.
unlink
(
fname
)
def
test_install_errorlog
(
self
):
self
.
configure
(
good_cfg
)
i
=
self
.
getOne
()
i
.
install_errorlog
()
app
=
i
.
getApp
()
self
.
assertEqual
(
app
.
error_log
.
meta_type
,
'Site Error Log'
)
self
.
assertTrue
(
app
.
_getInitializerFlag
(
'error_log'
))
def
test_install_products
(
self
):
self
.
configure
(
good_cfg
)
i
=
self
.
getOne
()
...
...
src/Products/SiteAccess/tests/testVirtualHostMonster.py
View file @
32f93f6d
...
...
@@ -17,7 +17,7 @@ class VHMRegressions(unittest.TestCase):
from
Testing.ZopeTestCase.ZopeLite
import
app
transaction
.
begin
()
self
.
app
=
makerequest
(
app
())
if
'virtual_hosting'
not
in
self
.
app
.
objectIds
():
if
'virtual_hosting'
not
in
self
.
app
.
objectIds
():
# If ZopeLite was imported, we have no default virtual
# host monster
from
Products.SiteAccess.VirtualHostMonster
\
...
...
src/Zope2/App/startup.py
View file @
32f93f6d
...
...
@@ -200,16 +200,15 @@ class ZPublisherExceptionHook:
# ouch, a user saw this conflict error :-(
self
.
unresolved_conflict_errors
+=
1
if
isinstance
(
published
,
list
):
# special case for zope root
error_log_url
=
''
else
:
error_log_url
=
''
if
not
isinstance
(
published
,
list
):
try
:
log
=
aq_acquire
(
published
,
'__error_log__'
,
containment
=
1
)
except
AttributeError
:
error_log_url
=
''
pass
else
:
error_log_url
=
log
.
raising
((
t
,
v
,
traceback
))
if
log
is
not
None
:
error_log_url
=
log
.
raising
((
t
,
v
,
traceback
))
if
(
REQUEST
is
None
or
(
getattr
(
REQUEST
.
get
(
'RESPONSE'
,
None
),
'_error_format'
,
''
)
...
...
src/webdav/tests/testPUT_factory.py
View file @
32f93f6d
import
unittest
import
Testing
import
Zope2
Zope2
.
startup
()
from
Products.SiteAccess.VirtualHostMonster
import
VirtualHostMonster
from
Testing.makerequest
import
makerequest
import
transaction
import
base64
...
...
@@ -14,24 +14,23 @@ class TestPUTFactory(unittest.TestCase):
def
setUp
(
self
):
self
.
app
=
makerequest
(
Zope2
.
app
())
try
:
# Make a manager user
uf
=
self
.
app
.
acl_users
uf
.
_doAddUser
(
'manager'
,
'secret'
,
[
'Manager'
],
[])
# Make a folder to put stuff into
self
.
app
.
manage_addFolder
(
'folder'
,
''
)
self
.
folder
=
self
.
app
.
folder
# Fake a WebDAV PUT request
request
=
self
.
app
.
REQUEST
request
[
'PARENTS'
]
=
[
self
.
app
]
request
[
'BODY'
]
=
'bar'
request
.
environ
[
'CONTENT_TYPE'
]
=
'text/plain'
request
.
environ
[
'REQUEST_METHOD'
]
=
'PUT'
request
.
environ
[
'WEBDAV_SOURCE_PORT'
]
=
1
request
.
_auth
=
auth_info
except
:
self
.
tearDown
()
raise
# Make a manager user
uf
=
self
.
app
.
acl_users
uf
.
_doAddUser
(
'manager'
,
'secret'
,
[
'Manager'
],
[])
# Make a folder to put stuff into
self
.
app
.
manage_addFolder
(
'folder'
,
''
)
self
.
folder
=
self
.
app
.
folder
# Setup VHM
vhm
=
VirtualHostMonster
()
vhm
.
addToContainer
(
self
.
app
)
# Fake a WebDAV PUT request
request
=
self
.
app
.
REQUEST
request
[
'PARENTS'
]
=
[
self
.
app
]
request
[
'BODY'
]
=
'bar'
request
.
environ
[
'CONTENT_TYPE'
]
=
'text/plain'
request
.
environ
[
'REQUEST_METHOD'
]
=
'PUT'
request
.
environ
[
'WEBDAV_SOURCE_PORT'
]
=
1
request
.
_auth
=
auth_info
def
tearDown
(
self
):
transaction
.
abort
()
...
...
@@ -69,7 +68,6 @@ class TestPUTFactory(unittest.TestCase):
self
.
assertTrue
(
'doc'
in
self
.
folder
.
objectIds
())
def
testCollector2261
(
self
):
from
OFS.Folder
import
manage_addFolder
from
OFS.DTMLMethod
import
addDTMLMethod
self
.
app
.
manage_addFolder
(
'A'
,
''
)
...
...
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