Beispiel #1
0
  def POST(self):
    response = {
        'status': '',
        'error': ''
      }

    try:
      configData = web.input()

      # TODO: Validate user input
      gs.generate_db_schema(pg.connect(configData))

      # TODO: store in session variable not global variable
      web.schema = schema.Schema()
      web.config = configData
      response['status'] = 'ok'
    except Exception, e:
      response['status'] = 'error'
      response['error'] = str(e)
Beispiel #2
0
      gs.generate_db_schema(pg.connect(configData))

      # TODO: store in session variable not global variable
      web.schema = schema.Schema()
      web.config = configData
      response['status'] = 'ok'
    except Exception, e:
      response['status'] = 'error'
      response['error'] = str(e)

    web.header('Content-Type','application/json; charset=utf-8', unique=True)
    return json.dumps(response)

def isTest():
  if 'WEBPY_ENV' is os.environ:
    return os.environ['WEBPY_ENV'] == 'test'
  else:
    return False

# TODO: Get global vars, create shared global instance of SQLSchema class.
# http://stackoverflow.com/questions/7512681/how-to-keep-a-variable-value-across-requests-in-web-py

web.app = web.application(urls, globals())

if (not isTest()) and  __name__ == "__main__":
  gs.generate_db_schema(pg.connect(cp.parse_file('dbbackend/db.cfg')))
  web.app.run()

web.schema = schema.Schema()
web.config = cp.parse_file('dbbackend/db.cfg')