Skip to content

Commit 9f29ad9

Browse files
committed
Readd db/db_save as deprecated methods
1 parent 1f32079 commit 9f29ad9

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

src/sage/misc/all__sagemath_objects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
from sage.misc.flatten import flatten
2222

23-
from sage.misc.persist import save, load, dumps, loads
23+
from sage.misc.persist import save, load, dumps, loads, db, db_save
2424

2525
from sage.misc.constant_function import ConstantFunction
2626

src/sage/misc/persist.pyx

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ comp = zlib
4444
comp_other = bz2
4545

4646
from sage.misc.sage_unittest import TestSuite
47-
47+
from sage.misc.superseded import deprecation
4848

4949
# We define two global dictionaries `already_pickled` and
5050
# `already_unpickled`, which are intended to help you to implement
@@ -1222,3 +1222,31 @@ def load_sage_element(cls, parent, dic_pic):
12221222
X._set_parent(parent)
12231223
X.__dict__ = SageUnpickler.loads(dic_pic)
12241224
return X
1225+
1226+
1227+
def db(name):
1228+
r"""
1229+
Load object with given name from the Sage database. Use x.db(name)
1230+
or db_save(x, name) to save objects to the database.
1231+
1232+
The database directory is ``$HOME/.sage/db``.
1233+
"""
1234+
deprecation(39012, "Directly use pickle/unpickle instead of db/db_save.")
1235+
1236+
from sage.misc.misc import SAGE_DB
1237+
return load('%s/%s' % (SAGE_DB, name))
1238+
1239+
1240+
def db_save(x, name=None):
1241+
r"""
1242+
Save x to the Sage database.
1243+
1244+
The database directory is ``$HOME/.sage/db``.
1245+
"""
1246+
deprecation(39012, "Directly use pickle/unpickle instead of db/db_save.")
1247+
1248+
try:
1249+
x.db(name)
1250+
except AttributeError:
1251+
from sage.misc.misc import SAGE_DB
1252+
save(x, '%s/%s' % (SAGE_DB, name))

0 commit comments

Comments
 (0)