Package dakweb :: Module webregister
[hide private]
[frames] | no frames]

Source Code for Module dakweb.webregister

 1  """ 
 2  @contact: Debian FTPMaster <ftpmaster@debian.org> 
 3  @copyright: 2014  Mark Hymers <mhy@debian.org> 
 4  @license: GNU General Public License version 2 or later 
 5  """ 
 6   
 7   
8 -class QueryRegister:
9 __shared_state = {} 10
11 - def __init__(self, *args, **kwargs):
12 self.__dict__ = self.__shared_state 13 14 if not getattr(self, 'initialised', False): 15 self.initialised = True 16 17 # Dictionary of query paths to help mappings 18 self.queries = {}
19
20 - def register_path(self, path, func):
21 self.queries[path] = func.__module__
22
23 - def get_paths(self):
24 return sorted(self.queries.keys())
25
26 - def get_path_help(self, path):
27 # We always register with the leading / 28 if not path.startswith('/'): 29 path = '/' + path 30 return self.queries.get(path, '/')
31 32 33 __all__ = ['QueryRegister'] 34