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
Joshua
zodb
Commits
e17bbd1d
Commit
e17bbd1d
authored
Nov 18, 2011
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dryed convenience functions a little
parent
7e84d9b4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
14 deletions
+17
-14
src/ZEO/__init__.py
src/ZEO/__init__.py
+7
-10
src/ZODB/DB.py
src/ZODB/DB.py
+10
-4
No files found.
src/ZEO/__init__.py
View file @
e17bbd1d
...
@@ -21,20 +21,17 @@ ZEO is now part of ZODB; ZODB's home on the web is
...
@@ -21,20 +21,17 @@ ZEO is now part of ZODB; ZODB's home on the web is
"""
"""
def
DB
(
*
args
,
**
kw
):
import
ZEO.ClientStorage
,
ZODB
return
ZODB
.
DB
(
ZEO
.
ClientStorage
.
ClientStorage
(
*
args
,
**
kw
))
def
connection
(
*
args
,
**
kw
):
db
=
DB
(
*
args
,
**
kw
)
conn
=
db
.
open
()
conn
.
onCloseCallback
(
db
.
close
)
return
conn
def
client
(
*
args
,
**
kw
):
def
client
(
*
args
,
**
kw
):
import
ZEO.ClientStorage
import
ZEO.ClientStorage
return
ZEO
.
ClientStorage
.
ClientStorage
(
*
args
,
**
kw
)
return
ZEO
.
ClientStorage
.
ClientStorage
(
*
args
,
**
kw
)
def
DB
(
*
args
,
**
kw
):
import
ZODB
return
ZODB
.
DB
(
client
(
*
args
,
**
kw
))
def
connection
(
*
args
,
**
kw
):
return
DB
(
*
args
,
**
kw
).
open_then_close_db_when_connection_closes
()
def
server
(
path
=
None
,
blob_dir
=
None
,
storage_conf
=
None
,
zeo_conf
=
None
,
def
server
(
path
=
None
,
blob_dir
=
None
,
storage_conf
=
None
,
zeo_conf
=
None
,
port
=
None
):
port
=
None
):
"""Convenience function to start a server for interactive exploration
"""Convenience function to start a server for interactive exploration
...
...
src/ZODB/DB.py
View file @
e17bbd1d
...
@@ -956,6 +956,15 @@ class DB(object):
...
@@ -956,6 +956,15 @@ class DB(object):
def
new_oid
(
self
):
def
new_oid
(
self
):
return
self
.
storage
.
new_oid
()
return
self
.
storage
.
new_oid
()
def
open_then_close_db_when_connection_closes
(
self
):
"""Create and return a connection.
When the connection closes, the database will close too.
"""
conn
=
self
.
open
()
conn
.
onCloseCallback
(
self
.
close
)
return
conn
class
ContextManager
:
class
ContextManager
:
"""PEP 343 context manager
"""PEP 343 context manager
...
@@ -1016,7 +1025,4 @@ class TransactionalUndo(object):
...
@@ -1016,7 +1025,4 @@ class TransactionalUndo(object):
return
"%s:%s"
%
(
self
.
_storage
.
sortKey
(),
id
(
self
))
return
"%s:%s"
%
(
self
.
_storage
.
sortKey
(),
id
(
self
))
def
connection
(
*
args
,
**
kw
):
def
connection
(
*
args
,
**
kw
):
db
=
DB
(
*
args
,
**
kw
)
return
DB
(
*
args
,
**
kw
).
open_then_close_db_when_connection_closes
()
conn
=
db
.
open
()
conn
.
onCloseCallback
(
db
.
close
)
return
conn
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