[Checkins] SVN: zc.buildout/branches/help-api/ - further fixes for """AttributeError: Buildout instance has no

Godefroid Chapelle gotcha at bubblenet.be
Sun Mar 29 17:20:02 EDT 2009


Log message for revision 98494:
  - further fixes for """AttributeError: Buildout instance has no 
    attribute '_logger'""" by providing reasonable defaults 
    within the Buildout constructor (related to the new 'allow-hosts' option)
    (patch by Gottfried Ganssauge) (ajung)

Changed:
  U   zc.buildout/branches/help-api/CHANGES.txt
  U   zc.buildout/branches/help-api/src/zc/buildout/buildout.py

-=-
Modified: zc.buildout/branches/help-api/CHANGES.txt
===================================================================
--- zc.buildout/branches/help-api/CHANGES.txt	2009-03-29 21:19:55 UTC (rev 98493)
+++ zc.buildout/branches/help-api/CHANGES.txt	2009-03-29 21:20:02 UTC (rev 98494)
@@ -7,7 +7,12 @@
 1.0.6 (unreleased)
 ==================
 
+- further fixes for """AttributeError: Buildout instance has no 
+  attribute '_logger'""" by providing reasonable defaults 
+  within the Buildout constructor (related to the new 'allow-hosts' option)
+  (patch by Gottfried Ganssauge) (ajung)
 
+
 1.0.5 (2008-06-10)
 ==================
 

Modified: zc.buildout/branches/help-api/src/zc/buildout/buildout.py
===================================================================
--- zc.buildout/branches/help-api/src/zc/buildout/buildout.py	2009-03-29 21:19:55 UTC (rev 98493)
+++ zc.buildout/branches/help-api/src/zc/buildout/buildout.py	2009-03-29 21:20:02 UTC (rev 98494)
@@ -122,16 +122,30 @@
         self._parts = []
         # provide some defaults before options are parsed
         # because while parsing options those attributes might be
-        # used already (Gottfried Ganssauage)
-        self._links = ()
+        # used already (Gottfried Ganssauge)
+        buildout_section = data.get ('buildout')
+        links = buildout_section and buildout_section.get('find-links', '')
+        self._links = links and links.split() or ()
+
+        allow_hosts = buildout_section and buildout_section.get(
+             'allow-hosts', '*').split('\n')
+        self._allow_hosts = tuple([host.strip() for host in allow_hosts 
+                                   if host.strip() != ''])
+
         self._buildout_dir = os.getcwd()
         self._logger = logging.getLogger('zc.buildout')
         self.offline = False
         self.newest = True
         
+        ##################################################################
+        ## WARNING!!!
+        ## ALL ATTRIBUTES MUST HAVE REASONABLE DEFAULTS AT THIS POINT
+        ## OTHERWISE ATTRIBUTEERRORS MIGHT HAPPEN ANY TIME
+        ##################################################################
         # initialize some attrs and buildout directories.
         options = self['buildout']
 
+        # now reinitialize
         links = options.get('find-links', '')
         self._links = links and links.split() or ()
         



More information about the Checkins mailing list