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
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
...
@@ -33,6 +33,8 @@ Features Added
Restructuring
Restructuring
+++++++++++++
+++++++++++++
- Removed persistent default code like the `error_log` and `temp_folder`.
- Removed persistent default content, including the `standard_error_message`
- Removed persistent default content, including the `standard_error_message`
template.
template.
...
...
src/OFS/Application.py
View file @
32f93f6d
...
@@ -23,7 +23,6 @@ from AccessControl.class_init import InitializeClass
...
@@ -23,7 +23,6 @@ from AccessControl.class_init import InitializeClass
from
AccessControl.Permission
import
ApplicationDefaultPermissions
from
AccessControl.Permission
import
ApplicationDefaultPermissions
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
from
App.ApplicationManager
import
ApplicationManager
from
App.ApplicationManager
import
ApplicationManager
from
App.config
import
getConfiguration
from
App
import
FactoryDispatcher
from
App
import
FactoryDispatcher
from
DateTime
import
DateTime
from
DateTime
import
DateTime
from
OFS.metaconfigure
import
get_packages_to_initialize
from
OFS.metaconfigure
import
get_packages_to_initialize
...
@@ -59,8 +58,8 @@ class Application(ApplicationDefaultPermissions,
...
@@ -59,8 +58,8 @@ class Application(ApplicationDefaultPermissions,
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
title
=
'Zope'
title
=
'Zope'
__defined_roles__
=
(
'Manager'
,
'Anonymous'
,
'Owner'
)
__defined_roles__
=
(
'Manager'
,
'Anonymous'
,
'Owner'
)
web__form__method
=
'GET'
__error_log__
=
None
isTopLevelPrincipiaApplicationObject
=
1
isTopLevelPrincipiaApplicationObject
=
1
manage_options
=
((
manage_options
=
((
...
@@ -70,25 +69,16 @@ class Application(ApplicationDefaultPermissions,
...
@@ -70,25 +69,16 @@ class Application(ApplicationDefaultPermissions,
Folder
.
Folder
.
manage_options
[
2
:]
Folder
.
Folder
.
manage_options
[
2
:]
)
)
p_
=
misc_
.
p_
p_
=
misc_
.
p_
misc_
=
misc_
.
misc_
misc_
=
misc_
.
misc_
_reserved_names
=
(
'Control_Panel'
,
)
_reserved_names
=
(
'Control_Panel'
,
'browser_id_manager'
,
'temp_folder'
)
# This class-default __allow_groups__ ensures that the
# This class-default __allow_groups__ ensures that the
# emergency user can still access the system if the top-level
# emergency user can still access the system if the top-level
# UserFolder is deleted. This is necessary to allow people
# UserFolder is deleted. This is necessary to allow people
# to replace the top-level UserFolder object.
# to replace the top-level UserFolder object.
__allow_groups__
=
UserFolder
()
__allow_groups__
=
UserFolder
()
# Set the universal default method to index_html
_object_manager_browser_default_id
=
'index_html'
_initializer_registry
=
None
def
__init__
(
self
):
def
__init__
(
self
):
# Initialize users
# Initialize users
uf
=
UserFolder
()
uf
=
UserFolder
()
...
@@ -98,7 +88,7 @@ class Application(ApplicationDefaultPermissions,
...
@@ -98,7 +88,7 @@ class Application(ApplicationDefaultPermissions,
def
id
(
self
):
def
id
(
self
):
try
:
try
:
return
self
.
REQUEST
[
'SCRIPT_NAME'
][
1
:]
return
self
.
REQUEST
[
'SCRIPT_NAME'
][
1
:]
except
:
except
(
KeyError
,
TypeError
)
:
return
self
.
title
return
self
.
title
def
title_and_id
(
self
):
def
title_and_id
(
self
):
...
@@ -197,20 +187,7 @@ class Application(ApplicationDefaultPermissions,
...
@@ -197,20 +187,7 @@ class Application(ApplicationDefaultPermissions,
together.
together.
"""
"""
# We're at the base of the path.
# We're at the base of the path.
return
(
''
,)
return
(
''
,
)
security
.
declarePrivate
(
'_setInitializerFlag'
)
def
_setInitializerFlag
(
self
,
flag
):
if
self
.
_initializer_registry
is
None
:
self
.
_initializer_registry
=
{}
self
.
_initializer_registry
[
flag
]
=
1
security
.
declarePrivate
(
'_getInitializerFlag'
)
def
_getInitializerFlag
(
self
,
flag
):
reg
=
self
.
_initializer_registry
if
reg
is
None
:
reg
=
{}
return
reg
.
get
(
flag
)
InitializeClass
(
Application
)
InitializeClass
(
Application
)
...
@@ -253,15 +230,10 @@ class AppInitializer:
...
@@ -253,15 +230,10 @@ class AppInitializer:
def
initialize
(
self
):
def
initialize
(
self
):
# make sure to preserve relative ordering of calls below.
# make sure to preserve relative ordering of calls below.
self
.
install_cp_and_products
()
self
.
install_cp_and_products
()
self
.
install_tempfolder_and_sdc
()
self
.
install_session_data_manager
()
self
.
install_browser_id_manager
()
self
.
install_required_roles
()
self
.
install_required_roles
()
self
.
install_inituser
()
self
.
install_inituser
()
self
.
install_errorlog
()
self
.
install_products
()
self
.
install_products
()
self
.
install_standards
()
self
.
install_standards
()
self
.
install_virtual_hosting
()
def
install_cp_and_products
(
self
):
def
install_cp_and_products
(
self
):
global
APP_MANAGER
global
APP_MANAGER
...
@@ -277,130 +249,6 @@ class AppInitializer:
...
@@ -277,130 +249,6 @@ class AppInitializer:
app
.
_objects
=
tuple
(
i
for
i
in
app
.
_objects
if
i
[
'id'
]
!=
'Control_Panel'
)
app
.
_objects
=
tuple
(
i
for
i
in
app
.
_objects
if
i
[
'id'
]
!=
'Control_Panel'
)
self
.
commit
(
'Removed persistent Control_Panel'
)
self
.
commit
(
'Removed persistent Control_Panel'
)
def
install_tempfolder_and_sdc
(
self
):
app
=
self
.
getApp
()
from
Products.ZODBMountPoint.MountedObject
import
manage_addMounts
,
\
MountedObject
from
Products.ZODBMountPoint.MountedObject
import
getConfiguration
as
\
getDBTabConfiguration
dbtab_config
=
getDBTabConfiguration
()
tf
=
getattr
(
app
,
'temp_folder'
,
None
)
if
getattr
(
tf
,
'meta_type'
,
None
)
==
MountedObject
.
meta_type
:
# tf is a MountPoint object. This means that the temp_folder
# couldn't be mounted properly (the meta_type would have been
# the meta type of the container class otherwise). The
# MountPoint object writes a message to zLOG so we don't
# need to.
return
if
tf
is
None
:
# do nothing if we've already installed one
if
not
app
.
_getInitializerFlag
(
'temp_folder'
):
if
dbtab_config
is
None
:
# DefaultConfiguration, do nothing
return
mount_paths
=
[
x
[
0
]
for
x
in
dbtab_config
.
listMountPaths
()
]
if
not
'/temp_folder'
in
mount_paths
:
# we won't be able to create the mount point properly
LOG
.
error
(
'Could not initialze a Temporary Folder because '
'a database was not configured to be mounted at '
'the /temp_folder mount point'
)
return
try
:
manage_addMounts
(
app
,
(
'/temp_folder'
,))
app
.
_setInitializerFlag
(
'temp_folder'
)
self
.
commit
(
'Added temp_folder'
)
tf
=
app
.
temp_folder
except
:
LOG
.
error
(
'Could not add a /temp_folder mount point due to an '
'error.'
,
exc_info
=
sys
.
exc_info
())
return
# Ensure that there is a transient object container in the temp folder
config
=
getConfiguration
()
if
not
hasattr
(
aq_base
(
tf
),
'session_data'
):
from
Products.Transience.Transience
import
TransientObjectContainer
addnotify
=
getattr
(
config
,
'session_add_notify_script_path'
,
None
)
delnotify
=
getattr
(
config
,
'session_delete_notify_script_path'
,
None
)
default_limit
=
1000
default_period_secs
=
20
default_timeout_mins
=
20
limit
=
getattr
(
config
,
'maximum_number_of_session_objects'
,
default_limit
)
timeout_spec
=
getattr
(
config
,
'session_timeout_minutes'
,
default_timeout_mins
)
period_spec
=
getattr
(
config
,
'session_resolution_seconds'
,
default_period_secs
)
if
addnotify
and
app
.
unrestrictedTraverse
(
addnotify
,
None
)
is
None
:
LOG
.
warn
(
'failed to use nonexistent "%s" script as '
'session-add-notify-script-path'
%
addnotify
)
addnotify
=
None
if
delnotify
and
app
.
unrestrictedTraverse
(
delnotify
,
None
)
is
None
:
LOG
.
warn
(
'failed to use nonexistent "%s" script as '
'session-delete-notify-script-path'
%
delnotify
)
delnotify
=
None
if
1
:
# Preserve indentation for diff
toc
=
TransientObjectContainer
(
'session_data'
,
'Session Data Container'
,
timeout_mins
=
timeout_spec
,
addNotification
=
addnotify
,
delNotification
=
delnotify
,
limit
=
limit
,
period_secs
=
period_spec
)
tf
.
_setObject
(
'session_data'
,
toc
)
tf_reserved
=
getattr
(
tf
,
'_reserved_names'
,
())
if
'session_data'
not
in
tf_reserved
:
tf
.
_reserved_names
=
tf_reserved
+
(
'session_data'
,)
self
.
commit
(
'Added session_data to temp_folder'
)
return
tf
# return the tempfolder object for test purposes
def
install_browser_id_manager
(
self
):
app
=
self
.
getApp
()
if
app
.
_getInitializerFlag
(
'browser_id_manager'
):
# do nothing if we've already installed one
return
# Ensure that a browser ID manager exists
if
not
hasattr
(
app
,
'browser_id_manager'
):
from
Products.Sessions.BrowserIdManager
import
BrowserIdManager
bid
=
BrowserIdManager
(
'browser_id_manager'
,
'Browser Id Manager'
)
app
.
_setObject
(
'browser_id_manager'
,
bid
)
# FIXME explicitely call manage_afterAdd, as sometimes
# events are initialized too late
browser_id_manager
=
app
.
browser_id_manager
browser_id_manager
.
manage_afterAdd
(
browser_id_manager
,
app
)
app
.
_setInitializerFlag
(
'browser_id_manager'
)
self
.
commit
(
'Added browser_id_manager'
)
def
install_session_data_manager
(
self
):
app
=
self
.
getApp
()
if
app
.
_getInitializerFlag
(
'session_data_manager'
):
# do nothing if we've already installed one
return
# Ensure that a session data manager exists
if
not
hasattr
(
app
,
'session_data_manager'
):
from
Products.Sessions.SessionDataManager
import
SessionDataManager
sdm
=
SessionDataManager
(
'session_data_manager'
,
title
=
'Session Data Manager'
,
path
=
'/temp_folder/session_data'
,
requestName
=
'SESSION'
)
app
.
_setObject
(
'session_data_manager'
,
sdm
)
# FIXME explicitely call manage_afterAdd, as sometimes
# events are initialized too late
session_data_manager
=
app
.
session_data_manager
session_data_manager
.
manage_afterAdd
(
session_data_manager
,
app
)
app
.
_setInitializerFlag
(
'session_data_manager'
)
self
.
commit
(
'Added session_data_manager'
)
def
install_required_roles
(
self
):
def
install_required_roles
(
self
):
app
=
self
.
getApp
()
app
=
self
.
getApp
()
...
@@ -439,47 +287,16 @@ class AppInitializer:
...
@@ -439,47 +287,16 @@ class AppInitializer:
transaction
.
get
().
note
(
'Migrated user folder'
)
transaction
.
get
().
note
(
'Migrated user folder'
)
transaction
.
commit
()
transaction
.
commit
()
def
install_errorlog
(
self
):
app
=
self
.
getApp
()
if
app
.
_getInitializerFlag
(
'error_log'
):
# do nothing if we've already installed one
return
# Install an error_log
if
not
hasattr
(
app
,
'error_log'
):
from
Products.SiteErrorLog.SiteErrorLog
import
SiteErrorLog
error_log
=
SiteErrorLog
()
app
.
_setObject
(
'error_log'
,
error_log
)
# FIXME explicitely call manage_afterAdd, as sometimes
# events are initialized too late
error_log
=
app
.
error_log
error_log
.
manage_afterAdd
(
error_log
,
app
)
app
.
_setInitializerFlag
(
'error_log'
)
self
.
commit
(
'Added site error_log at /error_log'
)
def
install_virtual_hosting
(
self
):
app
=
self
.
getApp
()
if
app
.
_getInitializerFlag
(
'virtual_hosting'
):
return
if
(
not
app
.
objectIds
(
'Virtual Host Monster'
)
and
not
hasattr
(
app
,
'virtual_hosting'
)):
from
Products.SiteAccess.VirtualHostMonster
\
import
VirtualHostMonster
vhm
=
VirtualHostMonster
()
vhm
.
id
=
'virtual_hosting'
vhm
.
addToContainer
(
app
)
app
.
_setInitializerFlag
(
'virtual_hosting'
)
self
.
commit
(
'Added virtual_hosting'
)
def
install_products
(
self
):
def
install_products
(
self
):
return
install_products
()
return
install_products
()
def
install_standards
(
self
):
def
install_standards
(
self
):
app
=
self
.
getApp
()
app
=
self
.
getApp
()
if
getattr
(
app
,
'_standard_objects_have_been_added'
,
None
)
is
None
:
if
getattr
(
app
,
'_standard_objects_have_been_added'
,
None
)
is
not
None
:
return
delattr
(
app
,
'_standard_objects_have_been_added'
)
delattr
(
app
,
'_standard_objects_have_been_added'
)
if
getattr
(
app
,
'_initializer_registry'
,
None
)
is
not
None
:
transaction
.
get
().
note
(
'Removed standard objects flag'
)
delattr
(
app
,
'_initializer_registry'
)
transaction
.
get
().
note
(
'Removed unused application attributes.'
)
transaction
.
commit
()
transaction
.
commit
()
...
...
src/OFS/tests/testAcquisition.py
View file @
32f93f6d
...
@@ -29,10 +29,9 @@ from AccessControl import ClassSecurityInfo
...
@@ -29,10 +29,9 @@ from AccessControl import ClassSecurityInfo
from
AccessControl.class_init
import
InitializeClass
from
AccessControl.class_init
import
InitializeClass
from
AccessControl.SecurityManagement
import
newSecurityManager
from
AccessControl.SecurityManagement
import
newSecurityManager
from
AccessControl.SecurityManagement
import
noSecurityManager
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.ImplPython
import
guarded_getattr
as
guarded_getattr_py
from
AccessControl.ImplC
import
guarded_getattr
as
guarded_getattr_c
from
AccessControl.ImplC
import
guarded_getattr
as
guarded_getattr_c
from
Products.SiteErrorLog.SiteErrorLog
import
SiteErrorLog
class
AllowedItem
(
SimpleItem
):
class
AllowedItem
(
SimpleItem
):
...
@@ -56,16 +55,6 @@ class ProtectedItem(SimpleItem):
...
@@ -56,16 +55,6 @@ class ProtectedItem(SimpleItem):
InitializeClass
(
ProtectedItem
)
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
):
class
TestGetAttr
(
unittest
.
TestCase
):
...
@@ -83,7 +72,6 @@ class TestGetAttr(unittest.TestCase):
...
@@ -83,7 +72,6 @@ class TestGetAttr(unittest.TestCase):
# Set up objects in the root that we want to aquire
# Set up objects in the root that we want to aquire
self
.
app
.
manage_addFolder
(
'plain_folder'
)
self
.
app
.
manage_addFolder
(
'plain_folder'
)
self
.
app
.
_setObject
(
'error_log2'
,
ProtectedSiteErrorLog
())
# We also want to be able to acquire simple attributes
# We also want to be able to acquire simple attributes
self
.
app
.
manage_addProperty
(
id
=
'simple_type'
,
type
=
'string'
,
value
=
'a string'
)
self
.
app
.
manage_addProperty
(
id
=
'simple_type'
,
type
=
'string'
,
value
=
'a string'
)
...
@@ -131,74 +119,13 @@ class TestGetAttr(unittest.TestCase):
...
@@ -131,74 +119,13 @@ class TestGetAttr(unittest.TestCase):
self
.
assertEqual
(
o
,
self
.
app
.
acl_users
)
self
.
assertEqual
(
o
,
self
.
app
.
acl_users
)
def
testAclUsersDenied
(
self
):
def
testAclUsersDenied
(
self
):
# XXX: Fails in 2.7.3
o
=
self
.
guarded_getattr
(
self
.
folder
.
denied
,
'acl_users'
)
o
=
self
.
guarded_getattr
(
self
.
folder
.
denied
,
'acl_users'
)
self
.
assertEqual
(
o
,
self
.
app
.
acl_users
)
self
.
assertEqual
(
o
,
self
.
app
.
acl_users
)
def
testAclUsersProtected
(
self
):
def
testAclUsersProtected
(
self
):
# XXX: Fails in 2.7.3 for Anonymous
o
=
self
.
guarded_getattr
(
self
.
folder
.
protected
,
'acl_users'
)
o
=
self
.
guarded_getattr
(
self
.
folder
.
protected
,
'acl_users'
)
self
.
assertEqual
(
o
,
self
.
app
.
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:
# Also test Richard Jones' use-case of acquiring a string:
def
testSimpleTypeAllowed
(
self
):
def
testSimpleTypeAllowed
(
self
):
...
@@ -206,12 +133,10 @@ class TestGetAttr(unittest.TestCase):
...
@@ -206,12 +133,10 @@ class TestGetAttr(unittest.TestCase):
self
.
assertEqual
(
o
,
'a string'
)
self
.
assertEqual
(
o
,
'a string'
)
def
testSimpleTypeDenied
(
self
):
def
testSimpleTypeDenied
(
self
):
# XXX: Fails in 2.7.3
o
=
self
.
guarded_getattr
(
self
.
folder
.
denied
,
'simple_type'
)
o
=
self
.
guarded_getattr
(
self
.
folder
.
denied
,
'simple_type'
)
self
.
assertEqual
(
o
,
'a string'
)
self
.
assertEqual
(
o
,
'a string'
)
def
testSimpleTypeProtected
(
self
):
def
testSimpleTypeProtected
(
self
):
# XXX: Fails in 2.7.3 for Anonymous
o
=
self
.
guarded_getattr
(
self
.
folder
.
protected
,
'simple_type'
)
o
=
self
.
guarded_getattr
(
self
.
folder
.
protected
,
'simple_type'
)
self
.
assertEqual
(
o
,
'a string'
)
self
.
assertEqual
(
o
,
'a string'
)
...
...
src/OFS/tests/testAppInitializer.py
View file @
32f93f6d
...
@@ -14,8 +14,6 @@
...
@@ -14,8 +14,6 @@
import
os
,
unittest
,
tempfile
,
cStringIO
import
os
,
unittest
,
tempfile
,
cStringIO
from
logging
import
getLogger
from
OFS.Application
import
Application
,
AppInitializer
from
OFS.Application
import
Application
,
AppInitializer
import
Zope2.Startup
import
Zope2.Startup
import
ZConfig
import
ZConfig
...
@@ -101,69 +99,6 @@ class TestInitialization( unittest.TestCase ):
...
@@ -101,69 +99,6 @@ class TestInitialization( unittest.TestCase ):
self
.
assertTrue
(
hasattr
(
app
,
'Control_Panel'
))
self
.
assertTrue
(
hasattr
(
app
,
'Control_Panel'
))
self
.
assertEqual
(
app
.
Control_Panel
.
meta_type
,
'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
):
def
test_install_required_roles
(
self
):
self
.
configure
(
good_cfg
)
self
.
configure
(
good_cfg
)
i
=
self
.
getOne
()
i
=
self
.
getOne
()
...
@@ -187,14 +122,6 @@ class TestInitialization( unittest.TestCase ):
...
@@ -187,14 +122,6 @@ class TestInitialization( unittest.TestCase ):
if
os
.
path
.
exists
(
fname
):
if
os
.
path
.
exists
(
fname
):
os
.
unlink
(
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
):
def
test_install_products
(
self
):
self
.
configure
(
good_cfg
)
self
.
configure
(
good_cfg
)
i
=
self
.
getOne
()
i
=
self
.
getOne
()
...
...
src/Products/SiteAccess/tests/testVirtualHostMonster.py
View file @
32f93f6d
...
@@ -17,7 +17,7 @@ class VHMRegressions(unittest.TestCase):
...
@@ -17,7 +17,7 @@ class VHMRegressions(unittest.TestCase):
from
Testing.ZopeTestCase.ZopeLite
import
app
from
Testing.ZopeTestCase.ZopeLite
import
app
transaction
.
begin
()
transaction
.
begin
()
self
.
app
=
makerequest
(
app
())
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
# If ZopeLite was imported, we have no default virtual
# host monster
# host monster
from
Products.SiteAccess.VirtualHostMonster
\
from
Products.SiteAccess.VirtualHostMonster
\
...
...
src/Zope2/App/startup.py
View file @
32f93f6d
...
@@ -200,16 +200,15 @@ class ZPublisherExceptionHook:
...
@@ -200,16 +200,15 @@ class ZPublisherExceptionHook:
# ouch, a user saw this conflict error :-(
# ouch, a user saw this conflict error :-(
self
.
unresolved_conflict_errors
+=
1
self
.
unresolved_conflict_errors
+=
1
if
isinstance
(
published
,
list
):
error_log_url
=
''
# special case for zope root
if
not
isinstance
(
published
,
list
):
error_log_url
=
''
else
:
try
:
try
:
log
=
aq_acquire
(
published
,
'__error_log__'
,
containment
=
1
)
log
=
aq_acquire
(
published
,
'__error_log__'
,
containment
=
1
)
except
AttributeError
:
except
AttributeError
:
error_log_url
=
''
pass
else
:
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
if
(
REQUEST
is
None
or
(
getattr
(
REQUEST
.
get
(
'RESPONSE'
,
None
),
'_error_format'
,
''
)
(
getattr
(
REQUEST
.
get
(
'RESPONSE'
,
None
),
'_error_format'
,
''
)
...
...
src/webdav/tests/testPUT_factory.py
View file @
32f93f6d
import
unittest
import
unittest
import
Testing
import
Zope2
import
Zope2
Zope2
.
startup
()
Zope2
.
startup
()
from
Products.SiteAccess.VirtualHostMonster
import
VirtualHostMonster
from
Testing.makerequest
import
makerequest
from
Testing.makerequest
import
makerequest
import
transaction
import
transaction
import
base64
import
base64
...
@@ -14,24 +14,23 @@ class TestPUTFactory(unittest.TestCase):
...
@@ -14,24 +14,23 @@ class TestPUTFactory(unittest.TestCase):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
app
=
makerequest
(
Zope2
.
app
())
self
.
app
=
makerequest
(
Zope2
.
app
())
try
:
# Make a manager user
# Make a manager user
uf
=
self
.
app
.
acl_users
uf
=
self
.
app
.
acl_users
uf
.
_doAddUser
(
'manager'
,
'secret'
,
[
'Manager'
],
[])
uf
.
_doAddUser
(
'manager'
,
'secret'
,
[
'Manager'
],
[])
# Make a folder to put stuff into
# Make a folder to put stuff into
self
.
app
.
manage_addFolder
(
'folder'
,
''
)
self
.
app
.
manage_addFolder
(
'folder'
,
''
)
self
.
folder
=
self
.
app
.
folder
self
.
folder
=
self
.
app
.
folder
# Setup VHM
# Fake a WebDAV PUT request
vhm
=
VirtualHostMonster
()
request
=
self
.
app
.
REQUEST
vhm
.
addToContainer
(
self
.
app
)
request
[
'PARENTS'
]
=
[
self
.
app
]
# Fake a WebDAV PUT request
request
[
'BODY'
]
=
'bar'
request
=
self
.
app
.
REQUEST
request
.
environ
[
'CONTENT_TYPE'
]
=
'text/plain'
request
[
'PARENTS'
]
=
[
self
.
app
]
request
.
environ
[
'REQUEST_METHOD'
]
=
'PUT'
request
[
'BODY'
]
=
'bar'
request
.
environ
[
'WEBDAV_SOURCE_PORT'
]
=
1
request
.
environ
[
'CONTENT_TYPE'
]
=
'text/plain'
request
.
_auth
=
auth_info
request
.
environ
[
'REQUEST_METHOD'
]
=
'PUT'
except
:
request
.
environ
[
'WEBDAV_SOURCE_PORT'
]
=
1
self
.
tearDown
()
request
.
_auth
=
auth_info
raise
def
tearDown
(
self
):
def
tearDown
(
self
):
transaction
.
abort
()
transaction
.
abort
()
...
@@ -69,7 +68,6 @@ class TestPUTFactory(unittest.TestCase):
...
@@ -69,7 +68,6 @@ class TestPUTFactory(unittest.TestCase):
self
.
assertTrue
(
'doc'
in
self
.
folder
.
objectIds
())
self
.
assertTrue
(
'doc'
in
self
.
folder
.
objectIds
())
def
testCollector2261
(
self
):
def
testCollector2261
(
self
):
from
OFS.Folder
import
manage_addFolder
from
OFS.DTMLMethod
import
addDTMLMethod
from
OFS.DTMLMethod
import
addDTMLMethod
self
.
app
.
manage_addFolder
(
'A'
,
''
)
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