Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91585001
open_zodb.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Nov 12, 11:12
Size
1 KB
Mime Type
text/x-python
Expires
Thu, Nov 14, 11:12 (2 d)
Engine
blob
Format
Raw Data
Handle
22287967
Attached To
R3127 blackdynamite
open_zodb.py
View Options
#!/usr/bin/env python
################################################################
import
transaction
from
traitlets.config
import
get_config
from
IPython
import
embed
import
ZODB
import
ZODB.FileStorage
################################################################
class
Command
:
def
__init__
(
self
,
cmd
):
self
.
cmd
=
cmd
def
__repr__
(
self
):
return
self
.
cmd
()
def
make_command
(
func
):
return
Command
(
func
)
@make_command
def
commit
():
transaction
.
commit
()
return
""
################################################################
if
__name__
==
'__main__'
:
import
argparse
parser
=
argparse
.
ArgumentParser
(
description
=
'BlackDynamite ZODB client'
)
parser
.
add_argument
(
'filename'
,
help
=
'filename containing the database to open'
)
args
=
parser
.
parse_args
()
storage
=
ZODB
.
FileStorage
.
FileStorage
(
args
.
filename
)
db
=
ZODB
.
DB
(
storage
)
connection
=
db
.
open
()
root
=
connection
.
root
c
=
get_config
()
c
.
InteractiveShellEmbed
.
colors
=
"Linux"
embed
(
config
=
c
,
banner1
=
f
"""
Your database is accessible as the object 'db'.
Your root is accessible in the object 'root'.
For any changes you do you should hit 'commit' to make them permanent
"""
)
Event Timeline
Log In to Comment