? mw.patch
Index: context.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/context/context.module,v
retrieving revision 1.1
diff -u -F^f -r1.1 context.module
--- context.module	11 Mar 2008 13:27:12 -0000	1.1
+++ context.module	22 Mar 2008 03:41:35 -0000
@@ -91,10 +91,17 @@ function context_set($space, $key = null
 }
 
 /**
- * Retrieves a context by space + (optional) key
+ * Retrieves a context by space + (optional) key. $callback specifies an array whose elements are a function and then an array of function arguments. The return value of this function call is stored in context and returned.
  */
-function context_get($space = null, $key = null) {
-  return context_context(CONTEXT_GET, $space, $key, null);
+function context_get($space = null, $key = null, $callback = NULL) {
+  if (!$return = context_context(CONTEXT_GET, $space, $key, null)) {
+    if ($callback) {
+      $function = array_shift($callback);
+      $return = call_user_func_array($function, $callback);
+      context_set($space, $key = null, $return);
+    }
+  }
+  return $return;
 }
 
 /**
