Advertisement
Guest User

Untitled

a guest
Apr 26th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1.  
  2. import ConfigParser
  3.  
  4. class Section(object):
  5. def __init__(self,conf,section_name):
  6. self.conf = conf
  7. self.section = section_name
  8.  
  9. def __getattr__(self,attr):
  10. print "getting the %s of the %s" % (attr,self.section)
  11. return self.conf.get(self.section,attr)
  12.  
  13. class Configuration(object):
  14. def __init__(self,config_file):
  15. self.config_file = config_file
  16. self.parser = ConfigParser.ConfigParser()
  17. self.parser.read(self.config_file)
  18.  
  19. def __get__(self,attr):
  20. print "is this even called ?"
  21. if attr:
  22. return getattr(self,attr)
  23. print "getting the %s section" % (attr)
  24. return Section(self,attr)
  25.  
  26.  
  27. class App(object):
  28. def __init__(self):
  29. self.config = Configuration("/etc/infomaniak.conf")
  30.  
  31. def start(self):
  32. bottle.run(host='',port=self.config.port)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement