A draft for a farm object to keep stuff for long running process

A wiki farm holds wikis and and keep farm meta data.

Parts of a wiki farm

This could be a very simple object. Here is a start of a code for this. This is just a quick hack I did when I wanted to try the effect of caching page lists.

   1 """
   2     MoinMoin farm - a cluster of wikis
   3 
   4     This module supply the Farm class and utilities
   5 """
   6 
   7 class _Farm:
   8     """ A wiki farm """
   9 
  10     def __init__(self):
  11         self._wikis = {}
  12 
  13     def getWiki(self, name):
  14         """ Get a wiki instance, or None """
  15         return self._wikis.get(name)
  16 
  17     def addWiki(self, name, wiki):
  18         """ Add a wiki to the farm """
  19 
  20         if self.getWiki(name):
  21             raise RuntimeError("%s: Wiki exists" % name)
  22 
  23         self._wikis[name] = wiki
  24 
  25 _farm = None
  26 
  27 def sharedFarm():
  28     """ Return the shared wiki farm """
  29     global _farm
  30     if _farm is None:
  31         _farm = _Farm()
  32     return _farm

MoinMoin: FarmClass (last edited 2007-10-29 19:10:22 by localhost)