PEATDB/PEATApp.py
def createDBonServerDialog(self):
        """Allow users with admin passwd to create a project
           on the remote MySql DB. Relstorage only."""
        import MySQLdb as mysql
        mpDlg = MultipleValDialog(title='Create DB on Server',
                                    initialvalues=(self.server, self.port,
                                                   self.project,'peatadmin','',self.username),
                                    labels=('server','port','project',
                                            'user','password','access list'),
                                    types=('string','int','string',
                                           'string','password','string'),
                                    parent=self.main)
        if not mpDlg.result:
            return
        server = mpDlg.results[0]
        port = mpDlg.results[1]
        dbname = mpDlg.results[2]
        user = mpDlg.results[3]
        passwd = mpDlg.results[4]
        access = mpDlg.results[5]
        try:
            db = mysql.connect(user=user, host=server,
                               passwd=passwd, port=port)
            c = db.cursor()
        except mysql.OperationalError, e:
            tkMessageBox.showinfo('Error',e)
            return
        try:
            cmd = "create database " + dbname + ";"
            c.execute(cmd)
        except Exception, e:
            tkMessageBox.showinfo('Error',e)
        try:
            cmd = "grant all privileges on " + dbname + ".* to " + "'"+access+"'"+ "@'%';"
            print cmd
            c.execute(cmd)
            c.execute('flush privileges;')
        except mysql.OperationalError, e:
            tkMessageBox.showinfo('Error',e)
            self.recordEvent('Failed to create project, check settings')
            return

        self.recordEvent('Project %s successfully created on %s' %(dbname,server))
        tkMessageBox.showinfo("Project created",
                              'Project %s successfully created on %s. '
                              'With access for users %s. '
                              'You may connect to this project now.' %(dbname,server,access))
        return
Allow users with admin passwd to create a project
           on the remote MySql DB. Relstorage only.
Allow users with admin passwd to create a project
on the remote MySql DB. Relstorage only.
Allow users with admin passwd to create a project on the remote MySql DB . Relstorage only .
def createDBonServerDialog(self):
        import MySQLdb as mysql
        mpDlg = MultipleValDialog(title='Create DB on Server',
                                    initialvalues=(self.server, self.port,
                                                   self.project,'peatadmin','',self.username),
                                    labels=('server','port','project',
                                            'user','password','access list'),
                                    types=('string','int','string',
                                           'string','password','string'),
                                    parent=self.main)
        if not mpDlg.result:
            return
        server = mpDlg.results[0]
        port = mpDlg.results[1]
        dbname = mpDlg.results[2]
        user = mpDlg.results[3]
        passwd = mpDlg.results[4]
        access = mpDlg.results[5]
        try:
            db = mysql.connect(user=user, host=server,
                               passwd=passwd, port=port)
            c = db.cursor()
        except mysql.OperationalError, e:
            tkMessageBox.showinfo('Error',e)
            return
        try:
            cmd = "create database " + dbname + ";"
            c.execute(cmd)
        except Exception, e:
            tkMessageBox.showinfo('Error',e)
        try:
            cmd = "grant all privileges on " + dbname + ".* to " + "'"+access+"'"+ "@'%';"
            print cmd
            c.execute(cmd)
            c.execute('flush privileges;')
        except mysql.OperationalError, e:
            tkMessageBox.showinfo('Error',e)
            self.recordEvent('Failed to create project, check settings')
            return
        self.recordEvent('Project %s successfully created on %s' %(dbname,server))
        tkMessageBox.showinfo("Project created",
                              'Project %s successfully created on %s. '
                              'With access for users %s. '
                              'You may connect to this project now.' %(dbname,server,access))
        return
def createDBonServerDialog ( self ) : import MySQLdb as mysql mpDlg = MultipleValDialog ( title = 'Create DB on Server' , initialvalues = ( self . server , self . port , self . project , 'peatadmin' , '' , self . username ) , labels = ( 'server' , 'port' , 'project' , 'user' , 'password' , 'access list' ) , types = ( 'string' , 'int' , 'string' , 'string' , 'password' , 'string' ) , parent = self . main ) if not mpDlg . result : return server = mpDlg . results [ 0 ] port = mpDlg . results [ 1 ] dbname = mpDlg . results [ 2 ] user = mpDlg . results [ 3 ] passwd = mpDlg . results [ 4 ] access = mpDlg . results [ 5 ] try : db = mysql . connect ( user = user , host = server , passwd = passwd , port = port ) c = db . cursor ( ) except mysql . OperationalError , e : tkMessageBox . showinfo ( 'Error' , e ) return try : cmd = "create database " + dbname + ";" c . execute ( cmd ) except Exception , e : tkMessageBox . showinfo ( 'Error' , e ) try : cmd = "grant all privileges on " + dbname + ".* to " + "'" + access + "'" + "@'%';" print cmd c . execute ( cmd ) c . execute ( 'flush privileges;' ) except mysql . OperationalError , e : tkMessageBox . showinfo ( 'Error' , e ) self . recordEvent ( 'Failed to create project, check settings' ) return self . recordEvent ( 'Project %s successfully created on %s' % ( dbname , server ) ) tkMessageBox . showinfo ( "Project created" , 'Project %s successfully created on %s. ' 'With access for users %s. ' 'You may connect to this project now.' % ( dbname , server , access ) ) return
Allow users with admin passwd to create a project
on the remote MySql DB.
Allow users with admin passwd to create a project on the remote MySql DB .
"""Allow users with admin passwd to create a project
           on the remote MySql DB. Relstorage only."""
self