[patch] Use document->cached in src/scripting/python/document.c

"M. Levinson" <[email protected]>
Newsgroups gmane.comp.web.links
Message-ID <[email protected]>
For consistency, here's a patch for the Python backend to match last week's
change to the Lua backend (in commit 7db8abf6e7ff43f059c4496e734c17337487db2c)
that accompanied the fix for bug 756.

_______________________________________________
elinks-dev mailing list
[email protected]
http://linuxfromscratch.org/mailman/listinfo/elinks-dev
src_scripting_python_document.c.diff (text/x-patch, 1.6 KB)
 src/scripting/python/document.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/scripting/python/document.c b/src/scripting/python/document.c
index c7a1399..76decbe 100644
--- a/src/scripting/python/document.c
+++ b/src/scripting/python/document.c
@@ -9,8 +9,9 @@
 #include "elinks.h"
 
 #include "cache/cache.h"
+#include "document/document.h"
+#include "document/view.h"
 #include "scripting/python/core.h"
-#include "session/location.h"
 #include "session/session.h"
 
 /* Python interface to get the current document's body. */
@@ -23,8 +24,9 @@ If a document is being viewed, return its body; otherwise return None.\n");
 static PyObject *
 python_current_document(PyObject *self, PyObject *args)
 {
-	if (python_ses && have_location(python_ses)) {
-		struct cache_entry *cached = find_in_cache(cur_loc(python_ses)->vs.uri);
+	if (python_ses && python_ses->doc_view
+	    && python_ses->doc_view->document) {
+		struct cache_entry *cached = python_ses->doc_view->document->cached;
 		struct fragment *f = cached ? cached->frag.next : NULL;
 
 		if (f) return PyString_FromStringAndSize(f->data, f->length);
@@ -45,8 +47,9 @@ otherwise return None.\n");
 static PyObject *
 python_current_header(PyObject *self, PyObject *args)
 {
-	if (python_ses && have_location(python_ses)) {
-		struct cache_entry *cached = find_in_cache(cur_loc(python_ses)->vs.uri);
+	if (python_ses && python_ses->doc_view
+	    && python_ses->doc_view->document) {
+		struct cache_entry *cached = python_ses->doc_view->document->cached;
 
 		if (cached && cached->head)
 			return PyString_FromString(cached->head);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.