Skip to content

Commit

Permalink
Changed the application reference key in the configuration file format
Browse files Browse the repository at this point in the history
 The application can also be any callable returning an Application so application_class is inappropriate.
  Also added the "settings" key to the quickstart template.
  • Loading branch information
agronholm committed Aug 30, 2015
1 parent 29e96a7 commit aa9fbcc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 5 additions & 4 deletions asphalt/core/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ def start(app_ctx: ApplicationContext):
with (project / 'config.yml').open('w') as f:
f.write("""\
---
application_class: {package}:{app_subclass}
application: {package}:{app_subclass}
components:
foo: {{}} # REPLACE ME
foo: {{}} # REPLACE ME
settings:
bar: 1 # REPLACE ME
logging:
version: 1
disable_existing_loggers: false
Expand Down Expand Up @@ -77,7 +79,6 @@ def start(app_ctx: ApplicationContext):
author='FILL IN HERE',
author_email='FILL IN HERE',
classifiers=[
'Intended Audience :: End Users/Desktop',
'Programming Language :: Python',
'Programming Language :: Python :: 3'
],
Expand Down Expand Up @@ -107,7 +108,7 @@ def run_from_config_file(config_file: Union[str, Path], unsafe: bool=False):
assert isinstance(config, dict), 'the YAML document root must be a dictionary'

# Instantiate and run the application
application_class = resolve_reference(config.pop('application_class', Application))
application_class = resolve_reference(config.pop('application', Application))
application = application_class(**config)
application.run()

Expand Down
8 changes: 5 additions & 3 deletions tests/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ def start(app_ctx: ApplicationContext):
assert isinstance(yaml.load(config_data), dict)
assert config_data == """\
---
application_class: example:ExampleProjectApplication
application: example:ExampleProjectApplication
components:
foo: {} # REPLACE ME
foo: {} # REPLACE ME
settings:
bar: 1 # REPLACE ME
logging:
version: 1
disable_existing_loggers: false
Expand Down Expand Up @@ -108,7 +110,7 @@ def test_run_from_config_file(tmpdir, unsafe):
path = tmpdir.join('test.yaml')
path.write("""\
---
application_class: {}
application: {}
components:
foo: {{}}
bar: {{}}
Expand Down

0 comments on commit aa9fbcc

Please sign in to comment.