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
f8c45562
Commit
f8c45562
authored
Mar 24, 2005
by
Stefan H. Holek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ZopeLite now is careful not to apply monkey patches to an already running Zope.
parent
aa0b42b0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
54 deletions
+76
-54
lib/python/Testing/ZopeTestCase/ZopeLite.py
lib/python/Testing/ZopeTestCase/ZopeLite.py
+75
-54
lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
+1
-0
No files found.
lib/python/Testing/ZopeTestCase/ZopeLite.py
View file @
f8c45562
...
...
@@ -45,19 +45,30 @@ def _exec(cmd):
_write
(
'Loading Zope, please stand by '
)
_start
=
time
.
time
()
# Configure logging
if
not
sys
.
modules
.
has_key
(
'logging'
):
def
_configure_logging
():
# Initialize the logging module
if
not
sys
.
modules
.
has_key
(
'logging'
):
import
logging
logging
.
basicConfig
()
# Debug mode is dog slow ...
import
App.config
config
=
App
.
config
.
getConfiguration
()
config
.
debug_mode
=
0
App
.
config
.
setConfiguration
(
config
)
def
_configure_debug_mode
():
# Switch off debug mode
import
App.config
config
=
App
.
config
.
getConfiguration
()
config
.
debug_mode
=
0
App
.
config
.
setConfiguration
(
config
)
def
_configure_client_cache
():
# Make sure we use a temporary client cache
import
App.config
config
=
App
.
config
.
getConfiguration
()
config
.
zeo_client_name
=
None
App
.
config
.
setConfiguration
(
config
)
_configure_logging
()
_configure_debug_mode
()
_configure_client_cache
()
# Need to import Zope2 early on as the
# ZTUtils package relies on it
_exec
(
'import Zope2'
)
import
Zope2
_exec
(
'import ZODB'
)
...
...
@@ -75,26 +86,31 @@ _write('.')
_exec
(
'import OFS.Application'
)
import
OFS.Application
import
App.ProductContext
_write
(
'.'
)
# Avoid expensive product import
def
_null_import_products
():
pass
OFS
.
Application
.
import_products
=
_null_import_products
# Avoid expensive product installation
def
_null_initialize
(
app
):
pass
OFS
.
Application
.
initialize
=
_null_initialize
# Avoid expensive help registration
def
_null_register_topic
(
self
,
id
,
topic
):
pass
App
.
ProductContext
.
ProductContext
.
registerHelpTopic
=
_null_register_topic
def
_null_register_title
(
self
,
title
):
pass
App
.
ProductContext
.
ProductContext
.
registerHelpTitle
=
_null_register_title
def
_null_register_help
(
self
,
directory
=
''
,
clear
=
1
,
title_re
=
None
):
pass
App
.
ProductContext
.
ProductContext
.
registerHelp
=
_null_register_help
# Make sure to use a temporary client cache
if
os
.
environ
.
get
(
'ZEO_CLIENT'
):
del
os
.
environ
[
'ZEO_CLIENT'
]
def
_apply_patches
():
# Avoid expensive product import
def
null_import_products
():
pass
OFS
.
Application
.
import_products
=
null_import_products
# Avoid expensive product installation
def
null_initialize
(
app
):
pass
OFS
.
Application
.
initialize
=
null_initialize
# Avoid expensive help registration
def
null_register_topic
(
self
,
id
,
topic
):
pass
App
.
ProductContext
.
ProductContext
.
registerHelpTopic
=
null_register_topic
def
null_register_title
(
self
,
title
):
pass
App
.
ProductContext
.
ProductContext
.
registerHelpTitle
=
null_register_title
def
null_register_help
(
self
,
directory
=
''
,
clear
=
1
,
title_re
=
None
):
pass
App
.
ProductContext
.
ProductContext
.
registerHelp
=
null_register_help
# Do not patch a running Zope
if
not
Zope2
.
_began_startup
:
_apply_patches
()
# Allow test authors to install Zope products into the test environment. Note
# that installProduct() must be called at module level - never from tests.
from
OFS.Application
import
get_folder_permissions
,
get_products
,
install_product
from
OFS.Folder
import
Folder
import
Products
...
...
@@ -103,13 +119,12 @@ _theApp = Zope2.app()
_installedProducts
=
{}
def
hasProduct
(
name
):
'''
Test
s if a product can be found along Products.__path__'''
'''
Check
s if a product can be found along Products.__path__'''
return
name
in
[
n
[
1
]
for
n
in
get_products
()]
def
installProduct
(
name
,
quiet
=
0
):
'''Installs a Zope product.'''
start
=
time
.
time
()
app
=
_theApp
meta_types
=
[]
if
not
_installedProducts
.
has_key
(
name
):
for
priority
,
product_name
,
index
,
product_dir
in
get_products
():
...
...
@@ -117,7 +132,7 @@ def installProduct(name, quiet=0):
if
not
quiet
:
_print
(
'Installing %s ... '
%
product_name
)
# We want to fail immediately if a product throws an exception
# during install, so we set the raise_exc flag.
install_product
(
a
pp
,
product_dir
,
product_name
,
meta_types
,
install_product
(
_theA
pp
,
product_dir
,
product_name
,
meta_types
,
get_folder_permissions
(),
raise_exc
=
1
)
_installedProducts
[
product_name
]
=
1
Products
.
meta_types
=
Products
.
meta_types
+
tuple
(
meta_types
)
...
...
@@ -125,26 +140,30 @@ def installProduct(name, quiet=0):
if
not
quiet
:
_print
(
'done (%.3fs)
\
n
'
%
(
time
.
time
()
-
start
))
break
else
:
if
name
!=
'SomeProduct'
:
# Ignore
the
skeleton tests :-P
if
name
!=
'SomeProduct'
:
# Ignore skeleton tests :-P
if
not
quiet
:
_print
(
'Installing %s ... NOT FOUND
\
n
'
%
name
)
# Loading the Control_Panel of an existing ZODB may take
# a while; print another dot if it does.
_s
=
time
.
time
();
_max
=
(
_s
-
_start
)
/
4
_exec
(
'_theApp.Control_Panel'
)
_cp
=
_theApp
.
Control_Panel
if
hasattr
(
_cp
,
'initialize_cache'
):
_
cp
.
initialize_cache
()
if
(
time
.
time
()
-
_s
)
>
_max
:
def
_load_control_panel
():
# Loading the Control_Panel of an existing ZODB may take
# a while; print another dot if it does.
start
=
time
.
time
(
)
max
=
(
start
-
_start
)
/
4
_exec
(
'_theApp.Control_Panel'
)
_
theApp
.
Control_Panel
if
(
time
.
time
()
-
start
)
>
max
:
_write
(
'.'
)
installProduct
(
'PluginIndexes'
,
1
)
# Must install first
installProduct
(
'OFSP'
,
1
)
#installProduct('ExternalMethod', 1)
#installProduct('ZSQLMethods', 1)
#installProduct('ZGadflyDA', 1)
#installProduct('MIMETools', 1)
#installProduct('MailHost', 1)
def
_install_products
():
installProduct
(
'PluginIndexes'
,
1
)
# Must install first
installProduct
(
'OFSP'
,
1
)
#installProduct('ExternalMethod', 1)
#installProduct('ZSQLMethods', 1)
#installProduct('ZGadflyDA', 1)
#installProduct('MIMETools', 1)
#installProduct('MailHost', 1)
_load_control_panel
()
_install_products
()
# So people can use ZopeLite.app()
app
=
Zope2
.
app
...
...
@@ -153,9 +172,11 @@ DB = Zope2.DB
configure
=
Zope2
.
configure
def
startup
():
pass
# Provide a ZODB sandbox factory
from
ZODB.DemoStorage
import
DemoStorage
def
sandbox
(
base
=
None
):
'''Returns
what amounts to
a sandbox copy of the base ZODB.'''
'''Returns a sandbox copy of the base ZODB.'''
if
base
is
None
:
base
=
Zope2
.
DB
base_storage
=
base
.
_storage
quota
=
getattr
(
base_storage
,
'_quota'
,
None
)
...
...
lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
View file @
f8c45562
...
...
@@ -6,6 +6,7 @@
- Removed warnhook.py, we now use the one from ZODB.tests.
- Removed doctest.py, we now use the one from zope.testing.
- Removed dochttp.py + test, we now use the one from zope.app.tests.
- ZopeLite now takes care not to monkey patch an already running Zope.
0.9.6
- Dropped support for Zope 2.5 as it lacks the setSecurityManager() API.
...
...
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