We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Contents Manager does not get passed config ?
I can't seem to have my custom contents manager receive a config.

In sessionmanager we seem to have `contents_manager = Instance('IPython.html.services.contents.manager.ContentsManager', args=())` but nowhere is it passed parent or config. Is that normal ?


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `IPython/html/services/sessions/sessionmanager.py`
Content:
```
1 """A base class session manager."""
2 
3 # Copyright (c) IPython Development Team.
4 # Distributed under the terms of the Modified BSD License.
5 
6 import uuid
7 import sqlite3
8 
9 from tornado import web
10 
11 from IPython.config.configurable import LoggingConfigurable
12 from IPython.utils.py3compat import unicode_type
13 from IPython.utils.traitlets import Instance
14 
15 
16 class SessionManager(LoggingConfigurable):
17 
18     kernel_manager = Instance('IPython.html.services.kernels.kernelmanager.MappingKernelManager')
19     contents_manager = Instance('IPython.html.services.contents.manager.ContentsManager', args=())
20     
21     # Session database initialized below
22     _cursor = None
23     _connection = None
24     _columns = {'session_id', 'path', 'kernel_id'}
25     
26     @property
27     def cursor(self):
28         """Start a cursor and create a database called 'session'"""
29         if self._cursor is None:
30             self._cursor = self.connection.cursor()
31             self._cursor.execute("""CREATE TABLE session 
32                 (session_id, path, kernel_id)""")
33         return self._cursor
34 
35     @property
36     def connection(self):
37         """Start a database connection"""
38         if self._connection is None:
39             self._connection = sqlite3.connect(':memory:')
40             self._connection.row_factory = sqlite3.Row
41         return self._connection
42         
43     def __del__(self):
44         """Close connection once SessionManager closes"""
45         self.cursor.close()
46 
47     def session_exists(self, path):
48         """Check to see if the session for a given notebook exists"""
49         self.cursor.execute("SELECT * FROM session WHERE path=?", (path,))
50         reply = self.cursor.fetchone()
51         if reply is None:
52             return False
53         else:
54             return True
55 
56     def new_session_id(self):
57         "Create a uuid for a new session"
58         return unicode_type(uuid.uuid4())
59 
60     def create_session(self, path=None, kernel_name=None):
61         """Creates a session and returns its model"""
62         session_id = self.new_session_id()
63         # allow nbm to specify kernels cwd
64         kernel_path = self.contents_manager.get_kernel_path(path=path)
65         kernel_id = self.kernel_manager.start_kernel(path=kernel_path,
66                                                      kernel_name=kernel_name)
67         return self.save_session(session_id, path=path,
68                                  kernel_id=kernel_id)
69 
70     def save_session(self, session_id, path=None, kernel_id=None):
71         """Saves the items for the session with the given session_id
72         
73         Given a session_id (and any other of the arguments), this method
74         creates a row in the sqlite session database that holds the information
75         for a session.
76         
77         Parameters
78         ----------
79         session_id : str
80             uuid for the session; this method must be given a session_id
81         path : str
82             the path for the given notebook
83         kernel_id : str
84             a uuid for the kernel associated with this session
85         
86         Returns
87         -------
88         model : dict
89             a dictionary of the session model
90         """
91         self.cursor.execute("INSERT INTO session VALUES (?,?,?)",
92             (session_id, path, kernel_id)
93         )
94         return self.get_session(session_id=session_id)
95 
96     def get_session(self, **kwargs):
97         """Returns the model for a particular session.
98         
99         Takes a keyword argument and searches for the value in the session
100         database, then returns the rest of the session's info.
101 
102         Parameters
103         ----------
104         **kwargs : keyword argument
105             must be given one of the keywords and values from the session database
106             (i.e. session_id, path, kernel_id)
107 
108         Returns
109         -------
110         model : dict
111             returns a dictionary that includes all the information from the 
112             session described by the kwarg.
113         """
114         if not kwargs:
115             raise TypeError("must specify a column to query")
116 
117         conditions = []
118         for column in kwargs.keys():
119             if column not in self._columns:
120                 raise TypeError("No such column: %r", column)
121             conditions.append("%s=?" % column)
122 
123         query = "SELECT * FROM session WHERE %s" % (' AND '.join(conditions))
124 
125         self.cursor.execute(query, list(kwargs.values()))
126         try:
127             row = self.cursor.fetchone()
128         except KeyError:
129             # The kernel is missing, so the session just got deleted.
130             row = None
131 
132         if row is None:
133             q = []
134             for key, value in kwargs.items():
135                 q.append("%s=%r" % (key, value))
136 
137             raise web.HTTPError(404, u'Session not found: %s' % (', '.join(q)))
138 
139         return self.row_to_model(row)
140 
141     def update_session(self, session_id, **kwargs):
142         """Updates the values in the session database.
143         
144         Changes the values of the session with the given session_id
145         with the values from the keyword arguments. 
146         
147         Parameters
148         ----------
149         session_id : str
150             a uuid that identifies a session in the sqlite3 database
151         **kwargs : str
152             the key must correspond to a column title in session database,
153             and the value replaces the current value in the session 
154             with session_id.
155         """
156         self.get_session(session_id=session_id)
157 
158         if not kwargs:
159             # no changes
160             return
161 
162         sets = []
163         for column in kwargs.keys():
164             if column not in self._columns:
165                 raise TypeError("No such column: %r" % column)
166             sets.append("%s=?" % column)
167         query = "UPDATE session SET %s WHERE session_id=?" % (', '.join(sets))
168         self.cursor.execute(query, list(kwargs.values()) + [session_id])
169 
170     def row_to_model(self, row):
171         """Takes sqlite database session row and turns it into a dictionary"""
172         if row['kernel_id'] not in self.kernel_manager:
173             # The kernel was killed or died without deleting the session.
174             # We can't use delete_session here because that tries to find
175             # and shut down the kernel.
176             self.cursor.execute("DELETE FROM session WHERE session_id=?", 
177                                 (row['session_id'],))
178             raise KeyError
179 
180         model = {
181             'id': row['session_id'],
182             'notebook': {
183                 'path': row['path']
184             },
185             'kernel': self.kernel_manager.kernel_model(row['kernel_id'])
186         }
187         return model
188 
189     def list_sessions(self):
190         """Returns a list of dictionaries containing all the information from
191         the session database"""
192         c = self.cursor.execute("SELECT * FROM session")
193         result = []
194         # We need to use fetchall() here, because row_to_model can delete rows,
195         # which messes up the cursor if we're iterating over rows.
196         for row in c.fetchall():
197             try:
198                 result.append(self.row_to_model(row))
199             except KeyError:
200                 pass
201         return result
202 
203     def delete_session(self, session_id):
204         """Deletes the row in the session database with given session_id"""
205         # Check that session exists before deleting
206         session = self.get_session(session_id=session_id)
207         self.kernel_manager.shutdown_kernel(session['kernel']['id'])
208         self.cursor.execute("DELETE FROM session WHERE session_id=?", (session_id,))
209
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/IPython/html/services/sessions/sessionmanager.py b/IPython/html/services/sessions/sessionmanager.py
--- a/IPython/html/services/sessions/sessionmanager.py
+++ b/IPython/html/services/sessions/sessionmanager.py
@@ -16,7 +16,7 @@
 class SessionManager(LoggingConfigurable):
 
     kernel_manager = Instance('IPython.html.services.kernels.kernelmanager.MappingKernelManager')
-    contents_manager = Instance('IPython.html.services.contents.manager.ContentsManager', args=())
+    contents_manager = Instance('IPython.html.services.contents.manager.ContentsManager')
     
     # Session database initialized below
     _cursor = None

{"golden_diff": "diff --git a/IPython/html/services/sessions/sessionmanager.py b/IPython/html/services/sessions/sessionmanager.py\n--- a/IPython/html/services/sessions/sessionmanager.py\n+++ b/IPython/html/services/sessions/sessionmanager.py\n@@ -16,7 +16,7 @@\n class SessionManager(LoggingConfigurable):\n \n     kernel_manager = Instance('IPython.html.services.kernels.kernelmanager.MappingKernelManager')\n-    contents_manager = Instance('IPython.html.services.contents.manager.ContentsManager', args=())\n+    contents_manager = Instance('IPython.html.services.contents.manager.ContentsManager')\n     \n     # Session database initialized below\n     _cursor = None\n", "issue": "Contents Manager does not get passed config ?\nI can't seem to have my custom contents manager receive a config.\n\nIn sessionmanager we seem to have `contents_manager = Instance('IPython.html.services.contents.manager.ContentsManager', args=())` but nowhere is it passed parent or config. Is that normal ?\n\n", "before_files": [{"content": "\"\"\"A base class session manager.\"\"\"\n\n# Copyright (c) IPython Development Team.\n# Distributed under the terms of the Modified BSD License.\n\nimport uuid\nimport sqlite3\n\nfrom tornado import web\n\nfrom IPython.config.configurable import LoggingConfigurable\nfrom IPython.utils.py3compat import unicode_type\nfrom IPython.utils.traitlets import Instance\n\n\nclass SessionManager(LoggingConfigurable):\n\n    kernel_manager = Instance('IPython.html.services.kernels.kernelmanager.MappingKernelManager')\n    contents_manager = Instance('IPython.html.services.contents.manager.ContentsManager', args=())\n    \n    # Session database initialized below\n    _cursor = None\n    _connection = None\n    _columns = {'session_id', 'path', 'kernel_id'}\n    \n    @property\n    def cursor(self):\n        \"\"\"Start a cursor and create a database called 'session'\"\"\"\n        if self._cursor is None:\n            self._cursor = self.connection.cursor()\n            self._cursor.execute(\"\"\"CREATE TABLE session \n                (session_id, path, kernel_id)\"\"\")\n        return self._cursor\n\n    @property\n    def connection(self):\n        \"\"\"Start a database connection\"\"\"\n        if self._connection is None:\n            self._connection = sqlite3.connect(':memory:')\n            self._connection.row_factory = sqlite3.Row\n        return self._connection\n        \n    def __del__(self):\n        \"\"\"Close connection once SessionManager closes\"\"\"\n        self.cursor.close()\n\n    def session_exists(self, path):\n        \"\"\"Check to see if the session for a given notebook exists\"\"\"\n        self.cursor.execute(\"SELECT * FROM session WHERE path=?\", (path,))\n        reply = self.cursor.fetchone()\n        if reply is None:\n            return False\n        else:\n            return True\n\n    def new_session_id(self):\n        \"Create a uuid for a new session\"\n        return unicode_type(uuid.uuid4())\n\n    def create_session(self, path=None, kernel_name=None):\n        \"\"\"Creates a session and returns its model\"\"\"\n        session_id = self.new_session_id()\n        # allow nbm to specify kernels cwd\n        kernel_path = self.contents_manager.get_kernel_path(path=path)\n        kernel_id = self.kernel_manager.start_kernel(path=kernel_path,\n                                                     kernel_name=kernel_name)\n        return self.save_session(session_id, path=path,\n                                 kernel_id=kernel_id)\n\n    def save_session(self, session_id, path=None, kernel_id=None):\n        \"\"\"Saves the items for the session with the given session_id\n        \n        Given a session_id (and any other of the arguments), this method\n        creates a row in the sqlite session database that holds the information\n        for a session.\n        \n        Parameters\n        ----------\n        session_id : str\n            uuid for the session; this method must be given a session_id\n        path : str\n            the path for the given notebook\n        kernel_id : str\n            a uuid for the kernel associated with this session\n        \n        Returns\n        -------\n        model : dict\n            a dictionary of the session model\n        \"\"\"\n        self.cursor.execute(\"INSERT INTO session VALUES (?,?,?)\",\n            (session_id, path, kernel_id)\n        )\n        return self.get_session(session_id=session_id)\n\n    def get_session(self, **kwargs):\n        \"\"\"Returns the model for a particular session.\n        \n        Takes a keyword argument and searches for the value in the session\n        database, then returns the rest of the session's info.\n\n        Parameters\n        ----------\n        **kwargs : keyword argument\n            must be given one of the keywords and values from the session database\n            (i.e. session_id, path, kernel_id)\n\n        Returns\n        -------\n        model : dict\n            returns a dictionary that includes all the information from the \n            session described by the kwarg.\n        \"\"\"\n        if not kwargs:\n            raise TypeError(\"must specify a column to query\")\n\n        conditions = []\n        for column in kwargs.keys():\n            if column not in self._columns:\n                raise TypeError(\"No such column: %r\", column)\n            conditions.append(\"%s=?\" % column)\n\n        query = \"SELECT * FROM session WHERE %s\" % (' AND '.join(conditions))\n\n        self.cursor.execute(query, list(kwargs.values()))\n        try:\n            row = self.cursor.fetchone()\n        except KeyError:\n            # The kernel is missing, so the session just got deleted.\n            row = None\n\n        if row is None:\n            q = []\n            for key, value in kwargs.items():\n                q.append(\"%s=%r\" % (key, value))\n\n            raise web.HTTPError(404, u'Session not found: %s' % (', '.join(q)))\n\n        return self.row_to_model(row)\n\n    def update_session(self, session_id, **kwargs):\n        \"\"\"Updates the values in the session database.\n        \n        Changes the values of the session with the given session_id\n        with the values from the keyword arguments. \n        \n        Parameters\n        ----------\n        session_id : str\n            a uuid that identifies a session in the sqlite3 database\n        **kwargs : str\n            the key must correspond to a column title in session database,\n            and the value replaces the current value in the session \n            with session_id.\n        \"\"\"\n        self.get_session(session_id=session_id)\n\n        if not kwargs:\n            # no changes\n            return\n\n        sets = []\n        for column in kwargs.keys():\n            if column not in self._columns:\n                raise TypeError(\"No such column: %r\" % column)\n            sets.append(\"%s=?\" % column)\n        query = \"UPDATE session SET %s WHERE session_id=?\" % (', '.join(sets))\n        self.cursor.execute(query, list(kwargs.values()) + [session_id])\n\n    def row_to_model(self, row):\n        \"\"\"Takes sqlite database session row and turns it into a dictionary\"\"\"\n        if row['kernel_id'] not in self.kernel_manager:\n            # The kernel was killed or died without deleting the session.\n            # We can't use delete_session here because that tries to find\n            # and shut down the kernel.\n            self.cursor.execute(\"DELETE FROM session WHERE session_id=?\", \n                                (row['session_id'],))\n            raise KeyError\n\n        model = {\n            'id': row['session_id'],\n            'notebook': {\n                'path': row['path']\n            },\n            'kernel': self.kernel_manager.kernel_model(row['kernel_id'])\n        }\n        return model\n\n    def list_sessions(self):\n        \"\"\"Returns a list of dictionaries containing all the information from\n        the session database\"\"\"\n        c = self.cursor.execute(\"SELECT * FROM session\")\n        result = []\n        # We need to use fetchall() here, because row_to_model can delete rows,\n        # which messes up the cursor if we're iterating over rows.\n        for row in c.fetchall():\n            try:\n                result.append(self.row_to_model(row))\n            except KeyError:\n                pass\n        return result\n\n    def delete_session(self, session_id):\n        \"\"\"Deletes the row in the session database with given session_id\"\"\"\n        # Check that session exists before deleting\n        session = self.get_session(session_id=session_id)\n        self.kernel_manager.shutdown_kernel(session['kernel']['id'])\n        self.cursor.execute(\"DELETE FROM session WHERE session_id=?\", (session_id,))\n", "path": "IPython/html/services/sessions/sessionmanager.py"}], "after_files": [{"content": "\"\"\"A base class session manager.\"\"\"\n\n# Copyright (c) IPython Development Team.\n# Distributed under the terms of the Modified BSD License.\n\nimport uuid\nimport sqlite3\n\nfrom tornado import web\n\nfrom IPython.config.configurable import LoggingConfigurable\nfrom IPython.utils.py3compat import unicode_type\nfrom IPython.utils.traitlets import Instance\n\n\nclass SessionManager(LoggingConfigurable):\n\n    kernel_manager = Instance('IPython.html.services.kernels.kernelmanager.MappingKernelManager')\n    contents_manager = Instance('IPython.html.services.contents.manager.ContentsManager')\n    \n    # Session database initialized below\n    _cursor = None\n    _connection = None\n    _columns = {'session_id', 'path', 'kernel_id'}\n    \n    @property\n    def cursor(self):\n        \"\"\"Start a cursor and create a database called 'session'\"\"\"\n        if self._cursor is None:\n            self._cursor = self.connection.cursor()\n            self._cursor.execute(\"\"\"CREATE TABLE session \n                (session_id, path, kernel_id)\"\"\")\n        return self._cursor\n\n    @property\n    def connection(self):\n        \"\"\"Start a database connection\"\"\"\n        if self._connection is None:\n            self._connection = sqlite3.connect(':memory:')\n            self._connection.row_factory = sqlite3.Row\n        return self._connection\n        \n    def __del__(self):\n        \"\"\"Close connection once SessionManager closes\"\"\"\n        self.cursor.close()\n\n    def session_exists(self, path):\n        \"\"\"Check to see if the session for a given notebook exists\"\"\"\n        self.cursor.execute(\"SELECT * FROM session WHERE path=?\", (path,))\n        reply = self.cursor.fetchone()\n        if reply is None:\n            return False\n        else:\n            return True\n\n    def new_session_id(self):\n        \"Create a uuid for a new session\"\n        return unicode_type(uuid.uuid4())\n\n    def create_session(self, path=None, kernel_name=None):\n        \"\"\"Creates a session and returns its model\"\"\"\n        session_id = self.new_session_id()\n        # allow nbm to specify kernels cwd\n        kernel_path = self.contents_manager.get_kernel_path(path=path)\n        kernel_id = self.kernel_manager.start_kernel(path=kernel_path,\n                                                     kernel_name=kernel_name)\n        return self.save_session(session_id, path=path,\n                                 kernel_id=kernel_id)\n\n    def save_session(self, session_id, path=None, kernel_id=None):\n        \"\"\"Saves the items for the session with the given session_id\n        \n        Given a session_id (and any other of the arguments), this method\n        creates a row in the sqlite session database that holds the information\n        for a session.\n        \n        Parameters\n        ----------\n        session_id : str\n            uuid for the session; this method must be given a session_id\n        path : str\n            the path for the given notebook\n        kernel_id : str\n            a uuid for the kernel associated with this session\n        \n        Returns\n        -------\n        model : dict\n            a dictionary of the session model\n        \"\"\"\n        self.cursor.execute(\"INSERT INTO session VALUES (?,?,?)\",\n            (session_id, path, kernel_id)\n        )\n        return self.get_session(session_id=session_id)\n\n    def get_session(self, **kwargs):\n        \"\"\"Returns the model for a particular session.\n        \n        Takes a keyword argument and searches for the value in the session\n        database, then returns the rest of the session's info.\n\n        Parameters\n        ----------\n        **kwargs : keyword argument\n            must be given one of the keywords and values from the session database\n            (i.e. session_id, path, kernel_id)\n\n        Returns\n        -------\n        model : dict\n            returns a dictionary that includes all the information from the \n            session described by the kwarg.\n        \"\"\"\n        if not kwargs:\n            raise TypeError(\"must specify a column to query\")\n\n        conditions = []\n        for column in kwargs.keys():\n            if column not in self._columns:\n                raise TypeError(\"No such column: %r\", column)\n            conditions.append(\"%s=?\" % column)\n\n        query = \"SELECT * FROM session WHERE %s\" % (' AND '.join(conditions))\n\n        self.cursor.execute(query, list(kwargs.values()))\n        try:\n            row = self.cursor.fetchone()\n        except KeyError:\n            # The kernel is missing, so the session just got deleted.\n            row = None\n\n        if row is None:\n            q = []\n            for key, value in kwargs.items():\n                q.append(\"%s=%r\" % (key, value))\n\n            raise web.HTTPError(404, u'Session not found: %s' % (', '.join(q)))\n\n        return self.row_to_model(row)\n\n    def update_session(self, session_id, **kwargs):\n        \"\"\"Updates the values in the session database.\n        \n        Changes the values of the session with the given session_id\n        with the values from the keyword arguments. \n        \n        Parameters\n        ----------\n        session_id : str\n            a uuid that identifies a session in the sqlite3 database\n        **kwargs : str\n            the key must correspond to a column title in session database,\n            and the value replaces the current value in the session \n            with session_id.\n        \"\"\"\n        self.get_session(session_id=session_id)\n\n        if not kwargs:\n            # no changes\n            return\n\n        sets = []\n        for column in kwargs.keys():\n            if column not in self._columns:\n                raise TypeError(\"No such column: %r\" % column)\n            sets.append(\"%s=?\" % column)\n        query = \"UPDATE session SET %s WHERE session_id=?\" % (', '.join(sets))\n        self.cursor.execute(query, list(kwargs.values()) + [session_id])\n\n    def row_to_model(self, row):\n        \"\"\"Takes sqlite database session row and turns it into a dictionary\"\"\"\n        if row['kernel_id'] not in self.kernel_manager:\n            # The kernel was killed or died without deleting the session.\n            # We can't use delete_session here because that tries to find\n            # and shut down the kernel.\n            self.cursor.execute(\"DELETE FROM session WHERE session_id=?\", \n                                (row['session_id'],))\n            raise KeyError\n\n        model = {\n            'id': row['session_id'],\n            'notebook': {\n                'path': row['path']\n            },\n            'kernel': self.kernel_manager.kernel_model(row['kernel_id'])\n        }\n        return model\n\n    def list_sessions(self):\n        \"\"\"Returns a list of dictionaries containing all the information from\n        the session database\"\"\"\n        c = self.cursor.execute(\"SELECT * FROM session\")\n        result = []\n        # We need to use fetchall() here, because row_to_model can delete rows,\n        # which messes up the cursor if we're iterating over rows.\n        for row in c.fetchall():\n            try:\n                result.append(self.row_to_model(row))\n            except KeyError:\n                pass\n        return result\n\n    def delete_session(self, session_id):\n        \"\"\"Deletes the row in the session database with given session_id\"\"\"\n        # Check that session exists before deleting\n        session = self.get_session(session_id=session_id)\n        self.kernel_manager.shutdown_kernel(session['kernel']['id'])\n        self.cursor.execute(\"DELETE FROM session WHERE session_id=?\", (session_id,))\n", "path": "IPython/html/services/sessions/sessionmanager.py"}]}