Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZODB
Commits
660845eb
Commit
660845eb
authored
Sep 18, 2008
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace spurious dependency on ZODB / transaction w/ fake jars.
parent
c58b0c7a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
42 deletions
+23
-42
src/persistent/tests/test_overriding_attrs.py
src/persistent/tests/test_overriding_attrs.py
+23
-42
No files found.
src/persistent/tests/test_overriding_attrs.py
View file @
660845eb
...
...
@@ -19,9 +19,15 @@ access methods.
$Id$
"""
from
persistent
import
Persistent
import
transaction
from
ZODB.tests.util
import
DB
from
persistent
import
Persistent
# ouch!
def
_resettingJar
():
from
persistent.tests.utils
import
ResettingJar
return
ResettingJar
()
def
_rememberingJar
():
from
persistent.tests.utils
import
RememberingJar
return
RememberingJar
()
class
SampleOverridingGetattr
(
Persistent
):
"""Example of overriding __getattr__
...
...
@@ -52,10 +58,8 @@ class SampleOverridingGetattr(Persistent):
We'll save the object, so it can be deactivated:
>>> db = DB()
>>> conn = db.open()
>>> conn.root()['o'] = o
>>> transaction.commit()
>>> jar = _resettingJar()
>>> jar.add(o)
>>> o._p_deactivate()
>>> o._p_changed
...
...
@@ -66,10 +70,6 @@ class SampleOverridingGetattr(Persistent):
And we see that the object was activated before calling the
__getattr__ method.
We always close databases after we use them:
>>> db.close()
"""
# Don't pretend we have any special attributes.
if
name
.
startswith
(
"__"
)
and
name
.
endswrith
(
"__"
):
...
...
@@ -118,10 +118,8 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
Next, we'll save the object in a database so that we can
deactivate it:
>>> db = DB()
>>> conn = db.open()
>>> conn.root()['o'] = o
>>> transaction.commit()
>>> jar = _rememberingJar()
>>> jar.add(o)
>>> o._p_deactivate()
>>> o._p_changed
...
...
@@ -149,10 +147,6 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
0
See the very important note in the comment below!
We always close databases after we use them:
>>> db.close()
"""
#################################################################
...
...
@@ -220,13 +214,11 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
>>> 'x' in o.__dict__
False
Next, we'll
save the object in a database so that
we can
Next, we'll
give the object a "remembering" jar so
we can
deactivate it:
>>> db = DB()
>>> conn = db.open()
>>> conn.root()['o'] = o
>>> transaction.commit()
>>> jar = _rememberingJar()
>>> jar.add(o)
>>> o._p_deactivate()
>>> o._p_changed
...
...
@@ -242,9 +234,9 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
>>> o._p_changed
1
Now, if commit:
Now, if
fake a
commit:
>>>
transaction.
commit()
>>>
jar.fake_
commit()
>>> o._p_changed
0
...
...
@@ -263,11 +255,6 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
0
>>> o.tmp_foo
3
We always close databases after we use them:
>>> db.close()
"""
#################################################################
...
...
@@ -320,13 +307,11 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
...
AttributeError: x
Next, we'll save the object in a
database
so that we can
Next, we'll save the object in a
jar
so that we can
deactivate it:
>>> db = DB()
>>> conn = db.open()
>>> conn.root()['o'] = o
>>> transaction.commit()
>>> jar = _rememberingJar()
>>> jar.add(o)
>>> o._p_deactivate()
>>> o._p_changed
...
...
@@ -347,9 +332,9 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
>>> o.tmp_z
3
Now, if commit:
Now, if
fake a
commit:
>>>
transaction.
commit()
>>>
jar.fake_
commit()
>>> o._p_changed
0
...
...
@@ -371,10 +356,6 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
...
AttributeError: tmp_z
We always close databases after we use them:
>>> db.close()
"""
#################################################################
...
...
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