summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pyload/AccountManager.py2
-rw-r--r--pyload/network/RequestFactory.py38
-rw-r--r--pyload/plugins/Request.py5
-rw-r--r--pyload/plugins/network/CurlRequest.py5
-rw-r--r--tests/other/test_requestFactory.py10
5 files changed, 33 insertions, 27 deletions
diff --git a/pyload/AccountManager.py b/pyload/AccountManager.py
index a476c75c1..ab753c2e4 100644
--- a/pyload/AccountManager.py
+++ b/pyload/AccountManager.py
@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
###############################################################################
-# Copyright(c) 2008-2012 pyLoad Team
+# Copyright(c) 2008-2013 pyLoad Team
# http://www.pyload.org
#
# This file is part of pyLoad.
diff --git a/pyload/network/RequestFactory.py b/pyload/network/RequestFactory.py
index e6015219f..472705409 100644
--- a/pyload/network/RequestFactory.py
+++ b/pyload/network/RequestFactory.py
@@ -1,28 +1,26 @@
# -*- coding: utf-8 -*-
-"""
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License,
- or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>.
-
- @author: mkaay, RaNaN
-"""
+###############################################################################
+# Copyright(c) 2008-2013 pyLoad Team
+# http://www.pyload.org
+#
+# This file is part of pyLoad.
+# pyLoad is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# Subjected to the terms and conditions in LICENSE
+#
+# @author: RaNaN
+###############################################################################
from Bucket import Bucket
-from CookieJar import CookieJar
from pyload.plugins.network.DefaultRequest import DefaultRequest, DefaultDownload
-class RequestFactory():
+
+class RequestFactory:
def __init__(self, core):
self.core = core
self.bucket = Bucket()
@@ -42,8 +40,8 @@ class RequestFactory():
def getRequest(self, context=None, klass=DefaultRequest):
""" Creates a request with new or given context """
- # also accepts cookiejars, not so nice, since it depends on implementation
- if isinstance(context, CookieJar):
+ # also accepts the context class directly
+ if isinstance(context, klass.CONTEXT_CLASS):
return klass(self.getConfig(), context)
elif context:
return klass(*context)
diff --git a/pyload/plugins/Request.py b/pyload/plugins/Request.py
index 5652b6425..8e8e0cc6b 100644
--- a/pyload/plugins/Request.py
+++ b/pyload/plugins/Request.py
@@ -38,11 +38,6 @@ class Request(object):
# TODO: content encoding? Could be handled globally
- @property
- def http(self):
- print "Deprecated usage of req.http, just use req instead"
- return self
-
def initContext(self):
""" Should be used to initialize everything from given context and options """
pass
diff --git a/pyload/plugins/network/CurlRequest.py b/pyload/plugins/network/CurlRequest.py
index 4630403df..e5adc8be1 100644
--- a/pyload/plugins/network/CurlRequest.py
+++ b/pyload/plugins/network/CurlRequest.py
@@ -64,6 +64,11 @@ class CurlRequest(Request):
# TODO: addAuth, addHeader
+ @property
+ def http(self):
+ print "Deprecated usage of req.http, just use req instead"
+ return self
+
def initContext(self):
self.initHandle()
diff --git a/tests/other/test_requestFactory.py b/tests/other/test_requestFactory.py
index 734d9c1fb..751e7f03b 100644
--- a/tests/other/test_requestFactory.py
+++ b/tests/other/test_requestFactory.py
@@ -17,6 +17,9 @@ class TestRequestFactory:
new_req = self.req.getRequest(req.getContext())
assert new_req.getContext() == req.getContext()
+ cj = CurlRequest.CONTEXT_CLASS()
+ assert self.req.getRequest(cj).context is cj
+
def test_get_request_class(self):
self.req.getRequest(None, CurlRequest)
@@ -26,5 +29,10 @@ class TestRequestFactory:
dl.close()
# with given request
- dl = self.req.getDownloadRequest(self.req.getRequest())
+ req = self.req.getRequest()
+ dl = self.req.getDownloadRequest(req)
+
+ assert req.context is dl.context
+ assert req.options is dl.options
+
dl.close() \ No newline at end of file