Commits

Kenneth Love committed e17e11d

made db select work based on dbs returned in r.info()

  • Participants
  • Parent commits 25a1ea8

Comments (0)

Files changed (2)

     r = get_redis_connection(session)
     return dict(db_size=r.dbsize())
 
+@app.context_processor
+def get_number_of_dbs():
+    r = get_redis_connection(session)
+    dbs = [int(key[2:]) for key in r.info().keys() if key.startswith('db')]
+    dbs.sort()
+    return dict(db_range=xrange(0, dbs[-1]+1))
+
 @app.route('/new', methods=['GET', 'POST'])
 def new_key():
     form = StringForm(request.form or None)

templates/layout.html

 		<fieldset>
 			<label for="id_redis_db">Current Redis DB:</label>
 			<select id="id_redis_db" name="redis_db">
-				{% for number in range(0, 10) %}
+				{% for number in db_range %}
 				<option value="{{ number }}" {% if number == session.redis_db %}selected{% endif %}>{{ number }}</option>
 				{% endfor %}
 			</select>