diff --git a/src/App/DocumentPy.xml b/src/App/DocumentPy.xml
index 7aa4b2304..3a11e634d 100644
--- a/src/App/DocumentPy.xml
+++ b/src/App/DocumentPy.xml
@@ -23,6 +23,11 @@
Save the document under a new name to disk
+
+
+ Load the document from the given path
+
+
Restore the document from disk
diff --git a/src/App/DocumentPyImp.cpp b/src/App/DocumentPyImp.cpp
index c5225ca11..9993d6bcd 100644
--- a/src/App/DocumentPyImp.cpp
+++ b/src/App/DocumentPyImp.cpp
@@ -88,6 +88,31 @@ PyObject* DocumentPy::saveAs(PyObject * args)
Py_Return;
}
+PyObject* DocumentPy::load(PyObject * args)
+{
+ char* filename=0;
+ if (!PyArg_ParseTuple(args, "s", &filename))
+ return NULL;
+ if (!filename || *filename == '\0') {
+ PyErr_Format(PyExc_ValueError, "Path is empty");
+ return NULL;
+ }
+
+ getDocumentPtr()->FileName.setValue(filename);
+ Base::FileInfo fi(filename);
+ if (!fi.isReadable()) {
+ PyErr_Format(PyExc_IOError, "No such file or directory: '%s'", filename);
+ return NULL;
+ }
+ try {
+ getDocumentPtr()->restore();
+ } catch (...) {
+ PyErr_Format(PyExc_IOError, "Reading from file '%s' failed", filename);
+ return NULL;
+ }
+ Py_Return;
+}
+
PyObject* DocumentPy::restore(PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) // convert args: Python->C