diff -r 617aaf211802 -r 455dc39cd212 ProjectPyramid/Project.py --- a/ProjectPyramid/Project.py Tue Aug 28 19:53:25 2012 +0200 +++ b/ProjectPyramid/Project.py Wed Aug 29 11:25:01 2012 +0200 @@ -61,6 +61,10 @@ """ Public method to define the Pyramid actions. """ + # TODO: create action for: prequest + # TODO: create action for: proutes + # TODO: create action for: pviews + # TODO: create action for: ptweens self.actions = [] self.selectProjectAct = E5Action(self.trUtf8('Current Pyramid Project'), @@ -76,7 +80,6 @@ )) self.selectProjectAct.triggered[()].connect(self.__selectProject) self.actions.append(self.selectProjectAct) - self.__setCurrentProject(None) ############################### ## create actions below ## @@ -171,7 +174,26 @@ )) self.setupDevelopAct.triggered[()].connect(self.__setupDevelop) self.actions.append(self.setupDevelopAct) - + + ############################### + ## database actions below ## + ############################### + + self.initializeDbAct = E5Action(self.trUtf8('Initialize Database'), + self.trUtf8('Initialize &Database'), + 0, 0, + self,'pyramid_initialize_database') + self.initializeDbAct.setStatusTip(self.trUtf8( + 'Initializes (or re-initializes) the database of the current' + ' Pyramid project')) + self.initializeDbAct.setWhatsThis(self.trUtf8( + """<b>Initialize Database</b>""" + """<p>Initializes (or re-initializes) the database of the current""" + """ Pyramid project.</p>""" + )) + self.initializeDbAct.triggered[()].connect(self.__initializeDatabase) + self.actions.append(self.initializeDbAct) + ################################## ## distribution actions below ## ################################## @@ -223,6 +245,8 @@ )) self.aboutPyramidAct.triggered[()].connect(self.__pyramidInfo) self.actions.append(self.aboutPyramidAct) + + self.__setCurrentProject(None) def initMenu(self): """ @@ -243,6 +267,8 @@ menu.addSeparator() menu.addAction(self.setupDevelopAct) menu.addSeparator() + menu.addAction(self.initializeDbAct) + menu.addSeparator() menu.addAction(self.runPythonShellAct) menu.addSeparator() menu.addAction(self.buildDistroAct) @@ -587,6 +613,12 @@ os.path.join(project, outputDir, "%language%", "LC_MESSAGES", "{0}.po".format(domain)) ] + + if self.__currentProject is None: + self.initializeDbAct.setEnabled(False) + else: + initCmd = self.__getInitDbCommand() + self.initializeDbAct.setEnabled(os.path.exists(initCmd)) def __project(self): """ @@ -733,12 +765,6 @@ Private slot to set up the development environment for the current project. """ title = self.trUtf8("Setup Development Environment") - - cmd = self.getPythonCommand() - args = [] - args.append("setup.py") - args.append("develop") - try: wd = self.__projectPath() except PyramidNoProjectSelectedException: @@ -748,6 +774,11 @@ ' created yet. Aborting...')) return + cmd = self.getPythonCommand() + args = [] + args.append("setup.py") + args.append("develop") + dia = PyramidDialog(title, msgSuccess = \ self.trUtf8("Pyramid development environment setup successfully.")) @@ -791,12 +822,57 @@ dia.exec_() ################################################################## + ## slots below implement database functions + ################################################################## + + def __getInitDbCommand(self): + """ + Private method to create the path to the initialization script. + + @return path to the initialization script (string) + """ + try: + cmd = "initialize_{0}_db".format(self.__project()) + return self.getPyramidCommand(cmd) + except PyramidNoProjectSelectedException: + E5MessageBox.warning(self.__ui, + self.trUtf8("Initialize Database"), + self.trUtf8('No current Pyramid project selected or no Pyramid project' + ' created yet. Aborting...')) + return "" + + def __initializeDatabase(self): + """ + Private slot to initialize the database of the Pyramid project. + """ + title = self.trUtf8("Initialize Database") + try: + projectPath = self.__projectPath() + except PyramidNoProjectSelectedException: + E5MessageBox.warning(self.__ui, + title, + self.trUtf8('No current Pyramid project selected or no Pyramid project' + ' created yet. Aborting...')) + return + + cmd = self.__getInitDbCommand() + args = [] + args.append("development.ini") + + dia = PyramidDialog(title, + msgSuccess = \ + self.trUtf8("Database initialized successfully.")) + res = dia.startProcess(cmd, args, projectPath) + if res: + dia.exec_() + + ################################################################## ## slots below implement documentation functions ################################################################## def __showDocumentation(self): """ - Private slot to show the helpviewer with the Pylons documentation. + Private slot to show the helpviewer with the Pyramid documentation. """ page = self.__plugin.getPreferences("PyramidDocUrl") self.__ui.launchHelpViewer(page)