- def _importme(self):
- self._debug_fn('importing...')
- for type, function in self._hooks:
- self._debug_fn('hooking %s into %s chain...' % (function, type))
- self._xmlrpc_handler.send_rpc('hook', self._in_fd, self._out_fd,
- id=self._id, type=type, call=function)
- return IkiWikiProcedureProxy._IKIWIKI_NIL_SENTINEL
+ def inject(self, rname, function, name=None, memoize=True):
+ if self._imported:
+ raise IkiWikiProcedureProxy.AlreadyImported
+
+ if name is None:
+ name = function.__name__
+
+ self._functions.append((rname, name, memoize))
+ self._xmlrpc_handler.register_function(function, name=name)
+
+ def getargv(self):
+ return self.rpc('getargv')
+
+ def setargv(self, argv):
+ return self.rpc('setargv', argv)
+
+ def getvar(self, hash, key):
+ return self.rpc('getvar', hash, key)
+
+ def setvar(self, hash, key, value):
+ return self.rpc('setvar', hash, key, value)
+
+ def getstate(self, page, id, key):
+ return self.rpc('getstate', page, id, key)
+
+ def setstate(self, page, id, key, value):
+ return self.rpc('setstate', page, id, key, value)
+
+ def pagespec_match(self, spec):
+ return self.rpc('pagespec_match', spec)
+
+ def error(self, msg):
+ try:
+ self.rpc('error', msg)
+ except IOError, e:
+ if e.errno != 32:
+ raise
+ import posix
+ sys.exit(posix.EX_SOFTWARE)