{"action":"created","issue":{"url":"https://api.github.com/repos/morepath/morepath/issues/378","repository_url":"https://api.github.com/repos/morepath/morepath","labels_url":"https://api.github.com/repos/morepath/morepath/issues/378/labels{/name}","comments_url":"https://api.github.com/repos/morepath/morepath/issues/378/comments","events_url":"https://api.github.com/repos/morepath/morepath/issues/378/events","html_url":"https://github.com/morepath/morepath/issues/378","id":147978362,"number":378,"title":"auto-commit application upon instantiation","user":{"login":"faassen","id":327472,"avatar_url":"https://avatars.githubusercontent.com/u/327472?v=3","gravatar_id":"","url":"https://api.github.com/users/faassen","html_url":"https://github.com/faassen","followers_url":"https://api.github.com/users/faassen/followers","following_url":"https://api.github.com/users/faassen/following{/other_user}","gists_url":"https://api.github.com/users/faassen/gists{/gist_id}","starred_url":"https://api.github.com/users/faassen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/faassen/subscriptions","organizations_url":"https://api.github.com/users/faassen/orgs","repos_url":"https://api.github.com/users/faassen/repos","events_url":"https://api.github.com/users/faassen/events{/privacy}","received_events_url":"https://api.github.com/users/faassen/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/morepath/morepath/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-04-13T07:56:49Z","updated_at":"2016-04-15T07:53:13Z","closed_at":"2016-04-15T07:34:29Z","body":"We could automatically commit the app as it gets instantiated. Some subtleties:\r\n\r\nIt should commit classes only once as mounting can instantiate frequently. And if an app mounts others it should recursively commit them right away, otherwise mounted apps would be committed during runtime.\r\n\r\nWe do not want to commit during import time, so instantiating an app at top level is potentially problematic. But maybe that is okay -- doing a manual commit in ``__main__`` has the same issue.\r\n\r\nWould it be possible to do this stuff in ``__new__`` so we don't put any requirement to do ``super`` on subclasses of ``App``?\r\n\r\n@taschini "},"comment":{"url":"https://api.github.com/repos/morepath/morepath/issues/comments/210344023","html_url":"https://github.com/morepath/morepath/issues/378#issuecomment-210344023","issue_url":"https://api.github.com/repos/morepath/morepath/issues/378","id":210344023,"user":{"login":"taschini","id":7879276,"avatar_url":"https://avatars.githubusercontent.com/u/7879276?v=3","gravatar_id":"","url":"https://api.github.com/users/taschini","html_url":"https://github.com/taschini","followers_url":"https://api.github.com/users/taschini/followers","following_url":"https://api.github.com/users/taschini/following{/other_user}","gists_url":"https://api.github.com/users/taschini/gists{/gist_id}","starred_url":"https://api.github.com/users/taschini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taschini/subscriptions","organizations_url":"https://api.github.com/users/taschini/orgs","repos_url":"https://api.github.com/users/taschini/repos","events_url":"https://api.github.com/users/taschini/events{/privacy}","received_events_url":"https://api.github.com/users/taschini/received_events","type":"User","site_admin":false},"created_at":"2016-04-15T07:53:13Z","updated_at":"2016-04-15T07:53:13Z","body":"Actually, I think there is a way forward.  We need first something like an ``app.commit_configuration`` class method that does the kind of recursive discovery and commit that you described (and motivated) above.\r\n\r\nThat would allow a line like the [following](https://github.com/morepath/morepath/blob/0257e4d13cec8f2f0689a07db287c1808dd20aa5/morepath/tests/test_scenario.py#L16):\r\n\r\n```\r\n    dectate.commit(app.Root, app.Generic, app.Document)\r\n```\r\n\r\nto be replaced by \r\n\r\n```\r\n    app.Root.commit_configuration()\r\n```\r\n\r\nSimilarly for the tests in [test_mount_directive.py](https://github.com/morepath/morepath/blob/0257e4d13cec8f2f0689a07db287c1808dd20aa5/morepath/tests/test_mount_directive.py).\r\n\r\nI think this first step is worthwhile even without the next step, which would have the app instance to invoke it unless `is_committed()` at some point before the first ``__call__()``.\r\n"}}