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
7ec49c4c
Commit
7ec49c4c
authored
Mar 29, 2005
by
Stefan H. Holek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ported r29693 from the trunk:
__builtin__.get_transaction() is officially deprecated in ZODB 3.4.
parent
2ca1aff5
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
24 deletions
+34
-24
lib/python/Testing/ZopeTestCase/doc/HOWTO.stx
lib/python/Testing/ZopeTestCase/doc/HOWTO.stx
+2
-2
lib/python/Testing/ZopeTestCase/testBaseTestCase.py
lib/python/Testing/ZopeTestCase/testBaseTestCase.py
+3
-1
lib/python/Testing/ZopeTestCase/testWebserver.py
lib/python/Testing/ZopeTestCase/testWebserver.py
+6
-4
lib/python/Testing/ZopeTestCase/testZODBCompat.py
lib/python/Testing/ZopeTestCase/testZODBCompat.py
+14
-12
lib/python/Testing/ZopeTestCase/utils.py
lib/python/Testing/ZopeTestCase/utils.py
+7
-4
lib/python/Testing/ZopeTestCase/zopedoctest/functional.py
lib/python/Testing/ZopeTestCase/zopedoctest/functional.py
+2
-1
No files found.
lib/python/Testing/ZopeTestCase/doc/HOWTO.stx
View file @
7ec49c4c
...
@@ -91,11 +91,11 @@ What You Get
...
@@ -91,11 +91,11 @@ What You Get
Hooks for controlling transactions:
Hooks for controlling transactions:
- **'beforeSetUp'** is called before the ZODB connection is opened, at the start of setUp.
- **'beforeSetUp'** is called before the ZODB connection is opened, at the start of setUp.
The default behaviour of this hook is to call '
get_transaction()
.begin()'.
The default behaviour of this hook is to call '
transaction
.begin()'.
You will rarely want to override this.
You will rarely want to override this.
- **'beforeClose'** is called before the ZODB connection is closed, at the end of
- **'beforeClose'** is called before the ZODB connection is closed, at the end of
tearDown. By default this method calls '
get_transaction()
.abort()' to discard
tearDown. By default this method calls '
transaction
.abort()' to discard
any changes made by the test. In some situations you may need to override
any changes made by the test. In some situations you may need to override
this hook and commit the transaction instead. Make sure you really know what
this hook and commit the transaction instead. Make sure you really know what
you are doing though.
you are doing though.
...
...
lib/python/Testing/ZopeTestCase/testBaseTestCase.py
View file @
7ec49c4c
...
@@ -26,6 +26,8 @@ import os, sys
...
@@ -26,6 +26,8 @@ import os, sys
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
execfile
(
os
.
path
.
join
(
sys
.
path
[
0
],
'framework.py'
))
execfile
(
os
.
path
.
join
(
sys
.
path
[
0
],
'framework.py'
))
import
transaction
from
Testing.ZopeTestCase
import
base
from
Testing.ZopeTestCase
import
base
from
Testing.ZopeTestCase
import
utils
from
Testing.ZopeTestCase
import
utils
...
@@ -146,7 +148,7 @@ class TestTestCase(HookTest):
...
@@ -146,7 +148,7 @@ class TestTestCase(HookTest):
def
getObjectsInTransaction
(
self
):
def
getObjectsInTransaction
(
self
):
# Lets us spy into the transaction
# Lets us spy into the transaction
t
=
get_transaction
()
t
=
transaction
.
get
()
if
hasattr
(
t
,
'_objects'
):
# Zope < 2.8
if
hasattr
(
t
,
'_objects'
):
# Zope < 2.8
return
t
.
_objects
return
t
.
_objects
elif
hasattr
(
t
,
'_resources'
):
# Zope >= 2.8
elif
hasattr
(
t
,
'_resources'
):
# Zope >= 2.8
...
...
lib/python/Testing/ZopeTestCase/testWebserver.py
View file @
7ec49c4c
...
@@ -41,6 +41,8 @@ from Testing import ZopeTestCase
...
@@ -41,6 +41,8 @@ from Testing import ZopeTestCase
from
AccessControl
import
Unauthorized
from
AccessControl
import
Unauthorized
import
urllib
import
urllib
import
transaction
# Create the error_log object
# Create the error_log object
ZopeTestCase
.
utils
.
setupSiteErrorLog
()
ZopeTestCase
.
utils
.
setupSiteErrorLog
()
...
@@ -84,11 +86,11 @@ class TestWebserver(ZopeTestCase.ZopeTestCase):
...
@@ -84,11 +86,11 @@ class TestWebserver(ZopeTestCase.ZopeTestCase):
self
.
folder
.
change_title
.
changeOwnership
(
manager
)
self
.
folder
.
change_title
.
changeOwnership
(
manager
)
# Commit so the ZServer threads can see the changes
# Commit so the ZServer threads can see the changes
get_transaction
()
.
commit
()
transaction
.
commit
()
def
beforeClose
(
self
):
def
beforeClose
(
self
):
# Commit after cleanup
# Commit after cleanup
get_transaction
()
.
commit
()
transaction
.
commit
()
def
testAccessPublicObject
(
self
):
def
testAccessPublicObject
(
self
):
# Test access to a public resource
# Test access to a public resource
...
@@ -188,9 +190,9 @@ class TestSandboxedWebserver(ZopeTestCase.Sandboxed, TestWebserver):
...
@@ -188,9 +190,9 @@ class TestSandboxedWebserver(ZopeTestCase.Sandboxed, TestWebserver):
# Additionally, it allows us to commit transactions without
# Additionally, it allows us to commit transactions without
# harming the test ZODB.
# harming the test ZODB.
self
.
folder
.
foo
=
1
self
.
folder
.
foo
=
1
get_transaction
()
.
commit
()
transaction
.
commit
()
self
.
folder
.
foo
=
2
self
.
folder
.
foo
=
2
get_transaction
()
.
commit
()
transaction
.
commit
()
def
test_suite
():
def
test_suite
():
...
...
lib/python/Testing/ZopeTestCase/testZODBCompat.py
View file @
7ec49c4c
...
@@ -25,6 +25,8 @@ if __name__ == '__main__':
...
@@ -25,6 +25,8 @@ if __name__ == '__main__':
from
Testing
import
ZopeTestCase
from
Testing
import
ZopeTestCase
import
transaction
from
AccessControl.Permissions
import
add_documents_images_and_files
from
AccessControl.Permissions
import
add_documents_images_and_files
from
AccessControl.Permissions
import
delete_objects
from
AccessControl.Permissions
import
delete_objects
import
tempfile
import
tempfile
...
@@ -40,7 +42,7 @@ class TestCopyPaste(ZopeTestCase.ZopeTestCase):
...
@@ -40,7 +42,7 @@ class TestCopyPaste(ZopeTestCase.ZopeTestCase):
self
.
folder
.
addDTMLMethod
(
'doc'
,
file
=
'foo'
)
self
.
folder
.
addDTMLMethod
(
'doc'
,
file
=
'foo'
)
# _p_oids are None until we commit a subtransaction
# _p_oids are None until we commit a subtransaction
self
.
assertEqual
(
self
.
folder
.
_p_oid
,
None
)
self
.
assertEqual
(
self
.
folder
.
_p_oid
,
None
)
get_transaction
()
.
commit
(
1
)
transaction
.
commit
(
1
)
self
.
failIfEqual
(
self
.
folder
.
_p_oid
,
None
)
self
.
failIfEqual
(
self
.
folder
.
_p_oid
,
None
)
def
testCutPaste
(
self
):
def
testCutPaste
(
self
):
...
@@ -91,7 +93,7 @@ class TestImportExport(ZopeTestCase.ZopeTestCase):
...
@@ -91,7 +93,7 @@ class TestImportExport(ZopeTestCase.ZopeTestCase):
self
.
folder
.
addDTMLMethod
(
'doc'
,
file
=
'foo'
)
self
.
folder
.
addDTMLMethod
(
'doc'
,
file
=
'foo'
)
# _p_oids are None until we commit a subtransaction
# _p_oids are None until we commit a subtransaction
self
.
assertEqual
(
self
.
folder
.
_p_oid
,
None
)
self
.
assertEqual
(
self
.
folder
.
_p_oid
,
None
)
get_transaction
()
.
commit
(
1
)
transaction
.
commit
(
1
)
self
.
failIfEqual
(
self
.
folder
.
_p_oid
,
None
)
self
.
failIfEqual
(
self
.
folder
.
_p_oid
,
None
)
def
testExport
(
self
):
def
testExport
(
self
):
...
@@ -169,7 +171,7 @@ class DummyObject(SimpleItem):
...
@@ -169,7 +171,7 @@ class DummyObject(SimpleItem):
app
=
ZopeTestCase
.
app
()
app
=
ZopeTestCase
.
app
()
app
.
_setObject
(
'dummy1'
,
DummyObject
())
app
.
_setObject
(
'dummy1'
,
DummyObject
())
app
.
_setObject
(
'dummy2'
,
DummyObject
())
app
.
_setObject
(
'dummy2'
,
DummyObject
())
get_transaction
()
.
commit
()
transaction
.
commit
()
ZopeTestCase
.
close
(
app
)
ZopeTestCase
.
close
(
app
)
...
@@ -306,45 +308,45 @@ class TestTransactionAbort(ZopeTestCase.ZopeTestCase):
...
@@ -306,45 +308,45 @@ class TestTransactionAbort(ZopeTestCase.ZopeTestCase):
def
testTransactionAbort
(
self
):
def
testTransactionAbort
(
self
):
self
.
folder
.
foo
=
1
self
.
folder
.
foo
=
1
self
.
failUnless
(
hasattr
(
self
.
folder
,
'foo'
))
self
.
failUnless
(
hasattr
(
self
.
folder
,
'foo'
))
get_transaction
()
.
abort
()
transaction
.
abort
()
# The foo attribute is still present
# The foo attribute is still present
self
.
failUnless
(
hasattr
(
self
.
folder
,
'foo'
))
self
.
failUnless
(
hasattr
(
self
.
folder
,
'foo'
))
def
testSubTransactionAbort
(
self
):
def
testSubTransactionAbort
(
self
):
self
.
folder
.
foo
=
1
self
.
folder
.
foo
=
1
self
.
failUnless
(
hasattr
(
self
.
folder
,
'foo'
))
self
.
failUnless
(
hasattr
(
self
.
folder
,
'foo'
))
get_transaction
()
.
commit
(
1
)
transaction
.
commit
(
1
)
get_transaction
()
.
abort
()
transaction
.
abort
()
# This time the abort nukes the foo attribute...
# This time the abort nukes the foo attribute...
self
.
failIf
(
hasattr
(
self
.
folder
,
'foo'
))
self
.
failIf
(
hasattr
(
self
.
folder
,
'foo'
))
def
testTransactionAbortPersistent
(
self
):
def
testTransactionAbortPersistent
(
self
):
self
.
folder
.
_p_foo
=
1
self
.
folder
.
_p_foo
=
1
self
.
failUnless
(
hasattr
(
self
.
folder
,
'_p_foo'
))
self
.
failUnless
(
hasattr
(
self
.
folder
,
'_p_foo'
))
get_transaction
()
.
abort
()
transaction
.
abort
()
# The _p_foo attribute is still present
# The _p_foo attribute is still present
self
.
failUnless
(
hasattr
(
self
.
folder
,
'_p_foo'
))
self
.
failUnless
(
hasattr
(
self
.
folder
,
'_p_foo'
))
def
testSubTransactionAbortPersistent
(
self
):
def
testSubTransactionAbortPersistent
(
self
):
self
.
folder
.
_p_foo
=
1
self
.
folder
.
_p_foo
=
1
self
.
failUnless
(
hasattr
(
self
.
folder
,
'_p_foo'
))
self
.
failUnless
(
hasattr
(
self
.
folder
,
'_p_foo'
))
get_transaction
()
.
commit
(
1
)
transaction
.
commit
(
1
)
get_transaction
()
.
abort
()
transaction
.
abort
()
# This time the abort nukes the _p_foo attribute...
# This time the abort nukes the _p_foo attribute...
self
.
failIf
(
hasattr
(
self
.
folder
,
'_p_foo'
))
self
.
failIf
(
hasattr
(
self
.
folder
,
'_p_foo'
))
def
testTransactionAbortVolatile
(
self
):
def
testTransactionAbortVolatile
(
self
):
self
.
folder
.
_v_foo
=
1
self
.
folder
.
_v_foo
=
1
self
.
failUnless
(
hasattr
(
self
.
folder
,
'_v_foo'
))
self
.
failUnless
(
hasattr
(
self
.
folder
,
'_v_foo'
))
get_transaction
()
.
abort
()
transaction
.
abort
()
# The _v_foo attribute is still present
# The _v_foo attribute is still present
self
.
failUnless
(
hasattr
(
self
.
folder
,
'_v_foo'
))
self
.
failUnless
(
hasattr
(
self
.
folder
,
'_v_foo'
))
def
testSubTransactionAbortVolatile
(
self
):
def
testSubTransactionAbortVolatile
(
self
):
self
.
folder
.
_v_foo
=
1
self
.
folder
.
_v_foo
=
1
self
.
failUnless
(
hasattr
(
self
.
folder
,
'_v_foo'
))
self
.
failUnless
(
hasattr
(
self
.
folder
,
'_v_foo'
))
get_transaction
()
.
commit
(
1
)
transaction
.
commit
(
1
)
get_transaction
()
.
abort
()
transaction
.
abort
()
# This time the abort nukes the _v_foo attribute...
# This time the abort nukes the _v_foo attribute...
self
.
failIf
(
hasattr
(
self
.
folder
,
'_v_foo'
))
self
.
failIf
(
hasattr
(
self
.
folder
,
'_v_foo'
))
...
...
lib/python/Testing/ZopeTestCase/utils.py
View file @
7ec49c4c
...
@@ -18,6 +18,8 @@ module level to add functionality to the test environment.
...
@@ -18,6 +18,8 @@ module level to add functionality to the test environment.
$Id: utils.py,v 1.21 2005/02/11 09:00:21 shh42 Exp $
$Id: utils.py,v 1.21 2005/02/11 09:00:21 shh42 Exp $
"""
"""
import
transaction
def
setupCoreSessions
(
app
=
None
):
def
setupCoreSessions
(
app
=
None
):
'''Sets up the session_data_manager e.a.'''
'''Sets up the session_data_manager e.a.'''
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
...
@@ -57,7 +59,8 @@ def setupCoreSessions(app=None):
...
@@ -57,7 +59,8 @@ def setupCoreSessions(app=None):
app
.
_setObject
(
'session_data_manager'
,
sdm
)
app
.
_setObject
(
'session_data_manager'
,
sdm
)
commit
=
1
commit
=
1
if
commit
:
get_transaction
().
commit
()
if
commit
:
transaction
.
commit
()
def
setupZGlobals
(
app
=
None
):
def
setupZGlobals
(
app
=
None
):
...
@@ -69,7 +72,7 @@ def setupZGlobals(app=None):
...
@@ -69,7 +72,7 @@ def setupZGlobals(app=None):
if
not
root
.
has_key
(
'ZGlobals'
):
if
not
root
.
has_key
(
'ZGlobals'
):
from
BTrees.OOBTree
import
OOBTree
from
BTrees.OOBTree
import
OOBTree
root
[
'ZGlobals'
]
=
OOBTree
()
root
[
'ZGlobals'
]
=
OOBTree
()
get_transaction
()
.
commit
()
transaction
.
commit
()
def
setupSiteErrorLog
(
app
=
None
):
def
setupSiteErrorLog
(
app
=
None
):
...
@@ -84,7 +87,7 @@ def setupSiteErrorLog(app=None):
...
@@ -84,7 +87,7 @@ def setupSiteErrorLog(app=None):
pass
pass
else
:
else
:
app
.
_setObject
(
'error_log'
,
SiteErrorLog
())
app
.
_setObject
(
'error_log'
,
SiteErrorLog
())
get_transaction
()
.
commit
()
transaction
.
commit
()
import
os
,
time
import
os
,
time
...
@@ -95,7 +98,7 @@ def importObjectFromFile(container, filename, quiet=0):
...
@@ -95,7 +98,7 @@ def importObjectFromFile(container, filename, quiet=0):
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
)
get_transaction
()
.
commit
()
transaction
.
commit
()
if
not
quiet
:
_print
(
'done (%.3fs)
\
n
'
%
(
time
.
time
()
-
start
))
if
not
quiet
:
_print
(
'done (%.3fs)
\
n
'
%
(
time
.
time
()
-
start
))
...
...
lib/python/Testing/ZopeTestCase/zopedoctest/functional.py
View file @
7ec49c4c
...
@@ -17,6 +17,7 @@ $Id: functional.py,v 1.2 2005/03/26 18:07:08 shh42 Exp $
...
@@ -17,6 +17,7 @@ $Id: functional.py,v 1.2 2005/03/26 18:07:08 shh42 Exp $
import
sys
,
re
,
base64
import
sys
,
re
,
base64
import
warnings
import
warnings
import
transaction
from
zope.testing
import
doctest
from
zope.testing
import
doctest
...
@@ -126,7 +127,7 @@ def http(request_string, handle_errors=True):
...
@@ -126,7 +127,7 @@ def http(request_string, handle_errors=True):
old_sm = getSecurityManager()
old_sm = getSecurityManager()
# Commit work done by previous python code.
# Commit work done by previous python code.
get_transaction()
.commit()
transaction
.commit()
# Discard leading white space to make call layout simpler
# Discard leading white space to make call layout simpler
request_string = request_string.lstrip()
request_string = request_string.lstrip()
...
...
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