59 |
59 |
60 def initActions(self): |
60 def initActions(self): |
61 """ |
61 """ |
62 Public method to define the Pyramid actions. |
62 Public method to define the Pyramid actions. |
63 """ |
63 """ |
|
64 # TODO: create action for: prequest |
|
65 # TODO: create action for: proutes |
|
66 # TODO: create action for: pviews |
|
67 # TODO: create action for: ptweens |
64 self.actions = [] |
68 self.actions = [] |
65 |
69 |
66 self.selectProjectAct = E5Action(self.trUtf8('Current Pyramid Project'), |
70 self.selectProjectAct = E5Action(self.trUtf8('Current Pyramid Project'), |
67 "", |
71 "", |
68 0, 0, |
72 0, 0, |
74 """<p>Selects the Pyramid project. Used for multi-project """ |
78 """<p>Selects the Pyramid project. Used for multi-project """ |
75 """Pyramid projects to switch between the projects.</p>""" |
79 """Pyramid projects to switch between the projects.</p>""" |
76 )) |
80 )) |
77 self.selectProjectAct.triggered[()].connect(self.__selectProject) |
81 self.selectProjectAct.triggered[()].connect(self.__selectProject) |
78 self.actions.append(self.selectProjectAct) |
82 self.actions.append(self.selectProjectAct) |
79 self.__setCurrentProject(None) |
|
80 |
83 |
81 ############################### |
84 ############################### |
82 ## create actions below ## |
85 ## create actions below ## |
83 ############################### |
86 ############################### |
84 |
87 |
169 """<p>Setup the Pyramid project in development mode using""" |
172 """<p>Setup the Pyramid project in development mode using""" |
170 """ "python setup.py develop".</p>""" |
173 """ "python setup.py develop".</p>""" |
171 )) |
174 )) |
172 self.setupDevelopAct.triggered[()].connect(self.__setupDevelop) |
175 self.setupDevelopAct.triggered[()].connect(self.__setupDevelop) |
173 self.actions.append(self.setupDevelopAct) |
176 self.actions.append(self.setupDevelopAct) |
174 |
177 |
|
178 ############################### |
|
179 ## database actions below ## |
|
180 ############################### |
|
181 |
|
182 self.initializeDbAct = E5Action(self.trUtf8('Initialize Database'), |
|
183 self.trUtf8('Initialize &Database'), |
|
184 0, 0, |
|
185 self,'pyramid_initialize_database') |
|
186 self.initializeDbAct.setStatusTip(self.trUtf8( |
|
187 'Initializes (or re-initializes) the database of the current' |
|
188 ' Pyramid project')) |
|
189 self.initializeDbAct.setWhatsThis(self.trUtf8( |
|
190 """<b>Initialize Database</b>""" |
|
191 """<p>Initializes (or re-initializes) the database of the current""" |
|
192 """ Pyramid project.</p>""" |
|
193 )) |
|
194 self.initializeDbAct.triggered[()].connect(self.__initializeDatabase) |
|
195 self.actions.append(self.initializeDbAct) |
|
196 |
175 ################################## |
197 ################################## |
176 ## distribution actions below ## |
198 ## distribution actions below ## |
177 ################################## |
199 ################################## |
178 |
200 |
179 self.buildDistroAct = E5Action(self.trUtf8('Build Distribution'), |
201 self.buildDistroAct = E5Action(self.trUtf8('Build Distribution'), |
221 """<b>About Pyramid</b>""" |
243 """<b>About Pyramid</b>""" |
222 """<p>Shows some information about Pyramid.</p>""" |
244 """<p>Shows some information about Pyramid.</p>""" |
223 )) |
245 )) |
224 self.aboutPyramidAct.triggered[()].connect(self.__pyramidInfo) |
246 self.aboutPyramidAct.triggered[()].connect(self.__pyramidInfo) |
225 self.actions.append(self.aboutPyramidAct) |
247 self.actions.append(self.aboutPyramidAct) |
|
248 |
|
249 self.__setCurrentProject(None) |
226 |
250 |
227 def initMenu(self): |
251 def initMenu(self): |
228 """ |
252 """ |
229 Public slot to initialize the Pyramid menu. |
253 Public slot to initialize the Pyramid menu. |
230 |
254 |
240 menu.addAction(self.runBrowserAct) |
264 menu.addAction(self.runBrowserAct) |
241 menu.addSeparator() |
265 menu.addSeparator() |
242 menu.addAction(self.createProjectAct) |
266 menu.addAction(self.createProjectAct) |
243 menu.addSeparator() |
267 menu.addSeparator() |
244 menu.addAction(self.setupDevelopAct) |
268 menu.addAction(self.setupDevelopAct) |
|
269 menu.addSeparator() |
|
270 menu.addAction(self.initializeDbAct) |
245 menu.addSeparator() |
271 menu.addSeparator() |
246 menu.addAction(self.runPythonShellAct) |
272 menu.addAction(self.runPythonShellAct) |
247 menu.addSeparator() |
273 menu.addSeparator() |
248 menu.addAction(self.buildDistroAct) |
274 menu.addAction(self.buildDistroAct) |
249 menu.addSeparator() |
275 menu.addSeparator() |
585 domain = config.get("init_catalog", "domain") |
611 domain = config.get("init_catalog", "domain") |
586 self.__e5project.pdata["TRANSLATIONPATTERN"] = [ |
612 self.__e5project.pdata["TRANSLATIONPATTERN"] = [ |
587 os.path.join(project, outputDir, "%language%", |
613 os.path.join(project, outputDir, "%language%", |
588 "LC_MESSAGES", "{0}.po".format(domain)) |
614 "LC_MESSAGES", "{0}.po".format(domain)) |
589 ] |
615 ] |
|
616 |
|
617 if self.__currentProject is None: |
|
618 self.initializeDbAct.setEnabled(False) |
|
619 else: |
|
620 initCmd = self.__getInitDbCommand() |
|
621 self.initializeDbAct.setEnabled(os.path.exists(initCmd)) |
590 |
622 |
591 def __project(self): |
623 def __project(self): |
592 """ |
624 """ |
593 Private method to get the name of the current Pyramid project. |
625 Private method to get the name of the current Pyramid project. |
594 |
626 |
731 def __setupDevelop(self): |
763 def __setupDevelop(self): |
732 """ |
764 """ |
733 Private slot to set up the development environment for the current project. |
765 Private slot to set up the development environment for the current project. |
734 """ |
766 """ |
735 title = self.trUtf8("Setup Development Environment") |
767 title = self.trUtf8("Setup Development Environment") |
|
768 try: |
|
769 wd = self.__projectPath() |
|
770 except PyramidNoProjectSelectedException: |
|
771 E5MessageBox.warning(self.__ui, |
|
772 title, |
|
773 self.trUtf8('No current Pyramid project selected or no Pyramid project' |
|
774 ' created yet. Aborting...')) |
|
775 return |
736 |
776 |
737 cmd = self.getPythonCommand() |
777 cmd = self.getPythonCommand() |
738 args = [] |
778 args = [] |
739 args.append("setup.py") |
779 args.append("setup.py") |
740 args.append("develop") |
780 args.append("develop") |
741 |
|
742 try: |
|
743 wd = self.__projectPath() |
|
744 except PyramidNoProjectSelectedException: |
|
745 E5MessageBox.warning(self.__ui, |
|
746 title, |
|
747 self.trUtf8('No current Pyramid project selected or no Pyramid project' |
|
748 ' created yet. Aborting...')) |
|
749 return |
|
750 |
781 |
751 dia = PyramidDialog(title, |
782 dia = PyramidDialog(title, |
752 msgSuccess = \ |
783 msgSuccess = \ |
753 self.trUtf8("Pyramid development environment setup successfully.")) |
784 self.trUtf8("Pyramid development environment setup successfully.")) |
754 res = dia.startProcess(cmd, args, wd) |
785 res = dia.startProcess(cmd, args, wd) |
789 res = dia.startProcess(cmd, args, projectPath) |
820 res = dia.startProcess(cmd, args, projectPath) |
790 if res: |
821 if res: |
791 dia.exec_() |
822 dia.exec_() |
792 |
823 |
793 ################################################################## |
824 ################################################################## |
|
825 ## slots below implement database functions |
|
826 ################################################################## |
|
827 |
|
828 def __getInitDbCommand(self): |
|
829 """ |
|
830 Private method to create the path to the initialization script. |
|
831 |
|
832 @return path to the initialization script (string) |
|
833 """ |
|
834 try: |
|
835 cmd = "initialize_{0}_db".format(self.__project()) |
|
836 return self.getPyramidCommand(cmd) |
|
837 except PyramidNoProjectSelectedException: |
|
838 E5MessageBox.warning(self.__ui, |
|
839 self.trUtf8("Initialize Database"), |
|
840 self.trUtf8('No current Pyramid project selected or no Pyramid project' |
|
841 ' created yet. Aborting...')) |
|
842 return "" |
|
843 |
|
844 def __initializeDatabase(self): |
|
845 """ |
|
846 Private slot to initialize the database of the Pyramid project. |
|
847 """ |
|
848 title = self.trUtf8("Initialize Database") |
|
849 try: |
|
850 projectPath = self.__projectPath() |
|
851 except PyramidNoProjectSelectedException: |
|
852 E5MessageBox.warning(self.__ui, |
|
853 title, |
|
854 self.trUtf8('No current Pyramid project selected or no Pyramid project' |
|
855 ' created yet. Aborting...')) |
|
856 return |
|
857 |
|
858 cmd = self.__getInitDbCommand() |
|
859 args = [] |
|
860 args.append("development.ini") |
|
861 |
|
862 dia = PyramidDialog(title, |
|
863 msgSuccess = \ |
|
864 self.trUtf8("Database initialized successfully.")) |
|
865 res = dia.startProcess(cmd, args, projectPath) |
|
866 if res: |
|
867 dia.exec_() |
|
868 |
|
869 ################################################################## |
794 ## slots below implement documentation functions |
870 ## slots below implement documentation functions |
795 ################################################################## |
871 ################################################################## |
796 |
872 |
797 def __showDocumentation(self): |
873 def __showDocumentation(self): |
798 """ |
874 """ |
799 Private slot to show the helpviewer with the Pylons documentation. |
875 Private slot to show the helpviewer with the Pyramid documentation. |
800 """ |
876 """ |
801 page = self.__plugin.getPreferences("PyramidDocUrl") |
877 page = self.__plugin.getPreferences("PyramidDocUrl") |
802 self.__ui.launchHelpViewer(page) |
878 self.__ui.launchHelpViewer(page) |
803 |
879 |
804 ################################################################## |
880 ################################################################## |