def test_database(self, request): """Check if the database uri is valid.""" database_uri = request.values.get('database_uri') error = None if not database_uri: error = 'You have to provide a database URI.' else: try: db.create_engine(database_uri, self.instance_folder) except Exception, e: error = str(e)
def start_setup(self, request): """ This is called when all the form data is validated and pyClanSphere is ready to install the data. In theory this can also be called if no form validation is done and someone faked the request. But because that's the fault of the administrator we don't care about that. """ value = request.values.get error = None database_uri = value('database_uri', '').strip() try: from pyClanSphere.database import init_database # create database and all tables e = db.create_engine(database_uri, self.instance_folder) init_database(e) except Exception, error: error = str(error).decode('utf-8', 'ignore')