Alain Poirier  committed 372345e

Fixes #1532.

The skeleton configuration file created by "nagare-admin create-app" doesn't contain all the possible parameters when their values are optionals.

But with this changeset, the `static` parameter, like all the others possible parameters, is now correctly available into the `config` object passed to the `set_config()` method:

from nagare import presentation, component, wsgi

class MyApp(object):

def render(self, h, *args):
return 'Hello world!'

class WSGIApp(wsgi.WSGIApp):
def set_config(self, filename, config, error):
super(WSGIApp, self).set_config(filename, config, error)
print 'Static directory:', config['application']['static']

app = WSGIApp(lambda: component.Component(MyApp()))

  • Participants
  • Parent commits 1b395ec

Comments (0)

Files changed (2)

File nagare/admin/

         requirement = None if not dist else pkg_resources.Requirement.parse(dist.project_name)
         data_path = None if not requirement else pkg_resources.resource_filename(requirement, '/data')
         # Create the function to get the static contents of the application
-        static_path = aconf['application'].get('static')
         get_file = None
+        static_path = aconf['application']['static']
         if static_path is not None and os.path.isdir(static_path):
-            # If a ``static`` parameter exists, under the ``[application]`` section,
-            # serve the static contents from this root
             get_file = lambda path, static_path=static_path: get_file_from_root(static_path, path)
-        else:
-            # Else, serve the static from the ``static`` directory
-            # of the application package
-            if requirement:
-                get_file = lambda path, requirement=requirement: get_file_from_package(requirement, path)
-                static_path = pkg_resources.resource_filename(requirement, '/static')
         # Register the function to serve the static contents of the application
         static_url = publisher.register_static(aconf['application']['name'], get_file)

File nagare/admin/

         redirect_after_post='boolean(default=False)',  # Follow the PRG pattern ?
         always_html='boolean(default=True)',  # Don't generate xhtml, even if it's a browser capability ?
-        wsgi_pipe='string(default="")'  # Method to create the WSGI middlewares pipe
+        wsgi_pipe='string(default="")',  # Method to create the WSGI middlewares pipe
+        static='string(default="$root/static")'  # Default directory of the static files
     'database': dict(