Skip to content
Browse files

make it possible to disable a site (setting enabled:falsish) and use …

…application_factory instead of type as the configuration key for setting the application factory class
  • Loading branch information...
1 parent f89d0ea commit 3e5edfeececcac2fad97fb9301c29ce651b3939a @nkvoll nkvoll committed
Showing with 10 additions and 6 deletions.
  1. +9 −5 contrib/cyclone/piped_cyclone/providers.py
  2. +1 −1 contrib/cyclone/piped_cyclone/test/test_cyclone.py
View
14 contrib/cyclone/piped_cyclone/providers.py
@@ -5,7 +5,7 @@
from twisted.application import strports
from twisted.python import reflect, filepath
-from piped import resource, exceptions
+from piped import resource, exceptions, log
from piped_cyclone import handlers
@@ -25,8 +25,8 @@ class CycloneProvider(object):
cyclone:
site_name:
- listen: 8888
- type: cyclone.web.Application # or a fully qualified name of a subclass
+ listen: 8888 # (default)
+ application_factory: cyclone.web.Application # (default) - a fully qualified name of a subclass
application:
handlers:
# a tuple: pattern, handler, kwargs (optional), name (optional)
@@ -106,9 +106,13 @@ def configure(self, runtime_environment):
cm = runtime_environment.configuration_manager
for name, config in cm.get(self.configuration_key, dict()).items():
+ if not config.get('enabled', True):
+ log.info('Not starting cyclone site [{0}] because it is disabled.'.format(name))
+ continue
+
listen = str(config.pop('listen', '8888'))
- application_factory_type = config.pop('type', 'cyclone.web.Application')
- application_factory = reflect.namedAny(application_factory_type)
+ application_factory_name = config.pop('application_factory', 'cyclone.web.Application')
+ application_factory = reflect.namedAny(application_factory_name)
application_config = config.pop('application', dict())
View
2 contrib/cyclone/piped_cyclone/test/test_cyclone.py
@@ -126,7 +126,7 @@ def test_simple(self):
def test_custom_app(self):
app = self.get_configured_cyclone(
- type = reflect.fullyQualifiedName(TestApplication)
+ application_factory = reflect.fullyQualifiedName(TestApplication)
)
self.assertIsInstance(app, TestApplication)

0 comments on commit 3e5edfe

Please sign in to comment.
Something went wrong with that request. Please try again.