title: Posting a python dictionary as an entered field on a form
body: <p>I am writing an application which will allow users to set up python scripts to run at set intervals. I am using APSCheduler combined with SQLAlchemy as a data source and Flask for my web UI.</p>
  
  <p>I have a screen with the following markup for setting up jobs:</p>
  
  <pre><code>&lt;form method="POST"&gt;
      &lt;input type="text" name="JobDesc"&gt;
      &lt;input type="text" name="function"&gt;
      &lt;input type="text" name="args"&gt;
      &lt;input type="text" name="kwargs"&gt;
      &lt;select name="trigger"&gt;
          &lt;option value="interval" selected&gt;Interval&lt;/option&gt; &lt;!--Adding other job types later--&gt;
      &lt;/select&gt;
      &lt;input type="number" name="minutes"&gt;
      &lt;select name="coalesce"&gt;
          &lt;option value=1&gt;True&lt;/option&gt;
          &lt;option value=0 selected&gt;False&lt;/option&gt;
      &lt;/select&gt;
      &lt;input type="submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>This forms "submit" button triggers the below script, to add the record to the database</p>
  
  <pre><code>@app.route('/addjob', methods=['GET', 'POST'])
  def JobConfig():
      if flask.request.method == 'POST':
  
          if flask.request.form['args'] == '': # '' == None returns False. :(
              args = None
          else:
              args = flask.request.form['args']
  
          if flask.request.form['kwargs'] == '':
              kwargs = None
          else:
              print(flask.request.form['kwargs'])
              kwargs = flask.request.form['kwargs']
  
          scheduler.add_job(
              trigger=str(flask.request.form['trigger']),
              func=str(flask.request.form['function']),
              minutes=int(flask.request.form['minutes']),
              coalesce=bool(flask.request.form['coalesce']),
              args=args,
              kwargs=kwargs,
              name=str(flask.request.form['JobDesc']),
          )
  
          return 'Success', 201
      elif flask.request.method == 'GET':
          return flask.render_template('JobEntry.html')
      else:
          return flask.abort(400)
  </code></pre>
  
  <p>APScheduler has a number of key fields:</p>
  
  <ul>
  <li>Function: Details of the function to be scheduled (for example: JOBS.TestJob:Test runs the Test function in the the Testjob.py file in the JOBS folder).</li>
  <li>args: List of functions to supply to the function.</li>
  <li>kwargs: Dictionary of functions to supply to the function.</li>
  </ul>
  
  <p>Unfortunately, while the entry screen works fine when args and kwargs are blank, if you try to entry any arguments I get an error. For example, if I the Test function is expecting an argument "Abbrev" and I enter {"Abbrev":"Test1"} into the kwargs field:</p>
  
  <pre><code>File "C:\Python34\lib\site-packages\apscheduler\schedulers\base.py", line 334, in add_job
  'kwargs': dict(kwargs) if kwargs is not None else {},
  ValueError: dictionary update sequence element #0 has length 1; 2 is required
  </code></pre>
  
  <p>Would anyone be able to point me in the right direction? I'm not sure if this is an error in my python of if I need to use something other than vanilla HTTP POST requests (JSON?) to send the data.</p>