From f3065fbb3ee0961ede57a9e95455cabc12bfb84e Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 18 Oct 2002 15:55:14 +0000 Subject: [PATCH] *** empty log message *** --- .../src/extensions/HTTPChannel-extensions.py | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 direct/src/extensions/HTTPChannel-extensions.py diff --git a/direct/src/extensions/HTTPChannel-extensions.py b/direct/src/extensions/HTTPChannel-extensions.py new file mode 100644 index 0000000000..9d322e6fe3 --- /dev/null +++ b/direct/src/extensions/HTTPChannel-extensions.py @@ -0,0 +1,34 @@ + + """ + HTTPChannel-extensions module: contains methods to extend functionality + of the HTTPChannel class + """ + + def spawnTask(self, name = None, callback = None, extraArgs = []): + """Spawns a task to service the download recently requested + via beginGetDocument(), etc., and/or downloadToFile() or + downloadToRam(). If a callback is specified, that function is + called when the download is complete, passing in the extraArgs + given. + + Returns the newly-spawned task. + """ + if not name: + name = self.getUrl().cStr() + + import Task + task = Task.Task(self.doTask) + task.callback = callback + task.extraArgs = extraArgs + + return taskMgr.add(task, name) + + def doTask(self, task): + import Task + if self.run(): + return Task.cont + + if task.callback: + task.callback(*task.extraArgs) + return Task.done +