Persistence In SimpleXMLRPCServer?

Brian Quinlan brian at sweetapp.com
Tue May 13 13:37:00 EDT 2003


> I have an XML-RPC server, with an instance that returns details of the
> local filesystem.  Is there a way I can have certain data cached (file
> stat data, for example), for use with each request?  I was thinking of
> something along the lines of self.server.xxxxx.
> 
> Is something like this possible, or will I have to store the data
> external?

I'm not sure what you mean. Why can't you just cache your data in the
instance that you register? e.g.

from SimpleXMLRPCServer import SimpleXMLRPCServer

class MyFileSystemStuff:
  def __init__(self):
    self.stat_cache = {}
  def stat(self, filename):		
    if self.stat_cache.has_key(filename):
      return self.stat_cache[filename]
    else:
      ....

server = ....
server.register_instance(MyFileSystemStuff())
server.serve_forever()

Cheers,
Brian






More information about the Python-list mailing list