1. Christian Theune
  2. sprintsite

Commits

Christian Theune  committed c2bce6d

Refactor gocept.net-platform component for nginx to make it more readable.

  • Participants
  • Parent commits 9012735
  • Branches default

Comments (0)

Files changed (1)

File components/nginx/component.py

View file
 
 
 @platform('gocept.net', Nginx)
-class SystemwideNginx(Component):
+class GoceptNetNginx(Component):
+    """Copies all config files to /etc/nginx/local and reloads nginx if
+    necessary.
+    """
 
     def configure(self):
-        # copy all .conf files in workingdir to /etc/nginx/local
-        # trigger sudo /etc/init.d/nginx reload
+        for config_file in self.config_files:
+            self += File(
+                '/etc/nginx/local/%s' % os.path.basename(config_file.path),
+                content=config_file.content)
+
+    @property
+    def config_files(self):
         for f in self.parent.sub_components:
             if not isinstance(f, File):
                 continue
             if not f.path.endswith('.conf'):
                 continue
-            # XXX why don't we just expand f.path to an absolute path
-            # automatically?
-            self += File(
-                '/etc/nginx/local/%s' % os.path.basename(f.path),
-                content=f.content)
+            yield f
 
     def verify(self):
         self.assert_no_subcomponent_changes()