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
e82f0feb
Commit
e82f0feb
authored
Mar 19, 2005
by
Christian Theune
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Ok. Fixed a failing test (StubDatabase) and checked in a doctest i forgot to add.
parent
1ceb36d8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
0 deletions
+89
-0
branches/pycon-multidb/src/ZODB/tests/testConnection.py
branches/pycon-multidb/src/ZODB/tests/testConnection.py
+2
-0
branches/pycon-multidb/src/ZODB/tests/testmultidb.py
branches/pycon-multidb/src/ZODB/tests/testmultidb.py
+87
-0
No files found.
branches/pycon-multidb/src/ZODB/tests/testConnection.py
View file @
e82f0feb
...
@@ -647,6 +647,8 @@ class StubDatabase:
...
@@ -647,6 +647,8 @@ class StubDatabase:
self
.
_storage
=
StubStorage
()
self
.
_storage
=
StubStorage
()
classFactory
=
None
classFactory
=
None
database_name
=
'stubdatabase'
databases
=
{
'stubdatabase'
:
database_name
}
def
invalidate
(
self
,
transaction
,
dict_with_oid_keys
,
connection
):
def
invalidate
(
self
,
transaction
,
dict_with_oid_keys
,
connection
):
pass
pass
...
...
branches/pycon-multidb/src/ZODB/tests/testmultidb.py
0 → 100644
View file @
e82f0feb
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
r"""
Multi-database tests
====================
Multi-database support adds the ability to tie multiple database into a
collection.
Creating a multi-database starts with creating a named DB:
>>> from ZODB.tests.test_storage import MinimalMemoryStorage
>>> from ZODB import DB
>>> db = DB(MinimalMemoryStorage(), database_name='root')
The database name is accessible afterwards and in a newly created collection:
>>> db.database_name
'root'
>>> db.databases # doctest: +ELLIPSIS
{'root': <ZODB.DB.DB object at ...>}
Adding a new database works like this:
>>> db2 = DB(MinimalMemoryStorage(),
... database_name='notroot',
... databases=db.databases)
The new db2 now shares the 'databases' dictionary with db and has two entries:
>>> db2.databases is db.databases
True
>>> len(db2.databases)
2
Trying to insert a database with a name that is already in use will not work:
>>> db3 = DB(MinimalMemoryStorage(),
... database_name='root',
... databases=db.databases)
Traceback (most recent call last):
... fancy traceback here ...
ValueError: database_name 'root' already in databases
You can (still) get a connection to a database this way:
>>> cn = db.open()
>>> cn # doctest: +ELLIPSIS
<Connection at ...>
This is the only connection in this collection right now:
>>> cn.connections # doctest: +ELLIPSIS
{'root': <Connection at ...>}
Getting a connection to a different database from an existing connection in the
same database collection (this enables 'connection binding' within a given
thread/transaction/context ...):
>>> cn2 = cn.get_connection('notroot')
>>> cn2 # doctest: +ELLIPSIS
<Connection at ...>
Now there are two connections in that collection:
>>> cn2.connections is cn.connections
True
>>> len(cn2.connections)
2
"""
from
zope.testing
import
doctest
def
test_suite
():
return
doctest
.
DocTestSuite
()
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