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
db473745
Commit
db473745
authored
Jul 23, 2016
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Sessions/Transience optional dependencies in ZTC.
parent
17089c2a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
38 deletions
+47
-38
src/Testing/ZopeTestCase/utils.py
src/Testing/ZopeTestCase/utils.py
+47
-38
No files found.
src/Testing/ZopeTestCase/utils.py
View file @
db473745
...
@@ -30,39 +30,46 @@ def setupCoreSessions(app):
...
@@ -30,39 +30,46 @@ def setupCoreSessions(app):
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
commit
=
0
commit
=
0
if
not
hasattr
(
app
,
'temp_folder'
):
try
:
from
Products.TemporaryFolder.TemporaryFolder
import
MountedTemporaryFolder
from
Products.TemporaryFolder.TemporaryFolder
import
\
tf
=
MountedTemporaryFolder
(
'temp_folder'
,
'Temporary Folder'
)
MountedTemporaryFolder
app
.
_setObject
(
'temp_folder'
,
tf
)
commit
=
1
if
not
hasattr
(
aq_base
(
app
.
temp_folder
),
'session_data'
):
from
Products.Transience.Transience
import
TransientObjectContainer
from
Products.Transience.Transience
import
TransientObjectContainer
toc
=
TransientObjectContainer
(
'session_data'
,
'Session Data Container'
,
timeout_mins
=
3
,
limit
=
100
)
app
.
temp_folder
.
_setObject
(
'session_data'
,
toc
)
commit
=
1
if
not
hasattr
(
app
,
'browser_id_manager'
):
from
Products.Sessions.BrowserIdManager
import
BrowserIdManager
from
Products.Sessions.BrowserIdManager
import
BrowserIdManager
bid
=
BrowserIdManager
(
'browser_id_manager'
,
'Browser Id Manager'
)
app
.
_setObject
(
'browser_id_manager'
,
bid
)
commit
=
1
if
not
hasattr
(
app
,
'session_data_manager'
):
from
Products.Sessions.SessionDataManager
import
SessionDataManager
from
Products.Sessions.SessionDataManager
import
SessionDataManager
sdm
=
SessionDataManager
(
'session_data_manager'
,
except
ImportError
:
title
=
'Session Data Manager'
,
pass
path
=
'/temp_folder/session_data'
,
else
:
requestName
=
'SESSION'
)
if
not
hasattr
(
app
,
'temp_folder'
):
app
.
_setObject
(
'session_data_manager'
,
sdm
)
tf
=
MountedTemporaryFolder
(
'temp_folder'
,
'Temporary Folder'
)
commit
=
1
app
.
_setObject
(
'temp_folder'
,
tf
)
commit
=
1
if
commit
:
transaction
.
commit
()
if
not
hasattr
(
aq_base
(
app
.
temp_folder
),
'session_data'
):
toc
=
TransientObjectContainer
(
'session_data'
,
'Session Data Container'
,
timeout_mins
=
3
,
limit
=
100
)
app
.
temp_folder
.
_setObject
(
'session_data'
,
toc
)
commit
=
1
if
not
hasattr
(
app
,
'browser_id_manager'
):
bid
=
BrowserIdManager
(
'browser_id_manager'
,
'Browser Id Manager'
)
app
.
_setObject
(
'browser_id_manager'
,
bid
)
commit
=
1
if
not
hasattr
(
app
,
'session_data_manager'
):
sdm
=
SessionDataManager
(
'session_data_manager'
,
title
=
'Session Data Manager'
,
path
=
'/temp_folder/session_data'
,
requestName
=
'SESSION'
)
app
.
_setObject
(
'session_data_manager'
,
sdm
)
commit
=
1
if
commit
:
transaction
.
commit
()
@
layer
.
appcall
@
layer
.
appcall
...
@@ -83,15 +90,18 @@ def importObjectFromFile(container, filename, quiet=0):
...
@@ -83,15 +90,18 @@ def importObjectFromFile(container, filename, quiet=0):
from
ZopeLite
import
_print
,
_patched
from
ZopeLite
import
_print
,
_patched
quiet
=
quiet
or
not
_patched
quiet
=
quiet
or
not
_patched
start
=
time
.
time
()
start
=
time
.
time
()
if
not
quiet
:
_print
(
"Importing %s ... "
%
os
.
path
.
basename
(
filename
))
if
not
quiet
:
_print
(
"Importing %s ... "
%
os
.
path
.
basename
(
filename
))
container
.
_importObjectFromFile
(
filename
,
verify
=
0
)
container
.
_importObjectFromFile
(
filename
,
verify
=
0
)
transaction
.
commit
()
transaction
.
commit
()
if
not
quiet
:
_print
(
'done (%.3fs)
\
n
'
%
(
time
.
time
()
-
start
))
if
not
quiet
:
_print
(
'done (%.3fs)
\
n
'
%
(
time
.
time
()
-
start
))
_Z2HOST
=
None
_Z2HOST
=
None
_Z2PORT
=
None
_Z2PORT
=
None
def
startZServer
(
number_of_threads
=
1
,
log
=
None
):
def
startZServer
(
number_of_threads
=
1
,
log
=
None
):
'''Starts an HTTP ZServer thread.'''
'''Starts an HTTP ZServer thread.'''
global
_Z2HOST
,
_Z2PORT
global
_Z2HOST
,
_Z2PORT
...
@@ -104,7 +114,7 @@ def startZServer(number_of_threads=1, log=None):
...
@@ -104,7 +114,7 @@ def startZServer(number_of_threads=1, log=None):
t
=
QuietThread
(
target
=
zserverRunner
,
args
=
(
_Z2HOST
,
_Z2PORT
,
log
))
t
=
QuietThread
(
target
=
zserverRunner
,
args
=
(
_Z2HOST
,
_Z2PORT
,
log
))
t
.
setDaemon
(
1
)
t
.
setDaemon
(
1
)
t
.
start
()
t
.
start
()
time
.
sleep
(
0.1
)
# Sandor Palfy
time
.
sleep
(
0.1
)
# Sandor Palfy
return
_Z2HOST
,
_Z2PORT
return
_Z2HOST
,
_Z2PORT
...
@@ -134,12 +144,12 @@ def makelist(arg):
...
@@ -134,12 +144,12 @@ def makelist(arg):
'''Turns arg into a list. Where arg may be
'''Turns arg into a list. Where arg may be
list, tuple, or string.
list, tuple, or string.
'''
'''
if
type
(
arg
)
==
type
([]
):
if
isinstance
(
arg
,
list
):
return
arg
return
arg
if
type
(
arg
)
==
type
(()
):
if
isinstance
(
arg
,
tuple
):
return
list
(
arg
)
return
list
(
arg
)
if
type
(
arg
)
==
type
(
''
):
if
isinstance
(
arg
,
str
):
return
filter
(
None
,
[
arg
])
return
filter
(
None
,
[
arg
])
raise
ValueError
(
'Argument must be list, tuple, or string'
)
raise
ValueError
(
'Argument must be list, tuple, or string'
)
...
@@ -152,4 +162,3 @@ __all__ = [
...
@@ -152,4 +162,3 @@ __all__ = [
'makerequest'
,
'makerequest'
,
'makelist'
,
'makelist'
,
]
]
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