def openAsPhpCallback(self, sender): u"""Save site as PHP template in MAMP area and then open it in the browser. This function assumes that a PHP server like MAMP is running. Otherwise the page will not open in the browser.""" view = self.getView() forceCopy = view.forceCopy.get() # Overwrite existing framework file? # Get the current selected site instance. site = self.getSite() # Save the current adapter for this site in order to restore it in the end. # The site instance is create on startup, and we don't want to destroy # the original default adapter that is already there. saveAdapter = site.adapter #site.adapter = PhpAdapter() # Create the site running with this adapter. rootPath = self.getMampRootPath(site) # Build the CSS and and PHP/HTML files in the MAMP directory. builder = CssBuilder() site.build(builder) # Build from entire site theme, not just from template. Result is stream in builder. # Copy the PHP framework on that position all files/directories the not yet exist. # Existing files will not be overwritten, unless the forceCopy flag is True. builder.makeDirectory(rootPath) builder.copyTree(self.PHP_SIMPLEMVC, rootPath, force=forceCopy) # Save the created output onto the framework template builder.save(site, root=rootPath + 'app/templates/default/') # Create the PhpBuilder instance that can build/modify the PHP file structure. builder = PhpBuilder() # Render the website as export file, positioned over the default PHP framework.. site.build(builder) # Build from entire site theme, not just from template. Result is stream in builder. # Copy the PHP frame work and save PHP/HTML files, builder.save(site, root=rootPath) # Restore the original adapter. site.adapter = saveAdapter # Open the site in the browser webbrowser.open('http://localhost:8888/%s/index.php' % site.getPythonClassName().lower())
def openAsPhpCallback(self, sender): u"""Save site as PHP template in MAMP area and then open it in the browser. This function assumes that a PHP server like MAMP is running. Otherwise the page will not open in the browser.""" view = self.getView() forceCopy = view.forceCopy.get() # Overwrite existing framework file? # Get the current selected site instance. site = self.getSite() # Save the current adapter for this site in order to restore it in the end. # The site instance is create on startup, and we don't want to destroy # the original default adapter that is already there. saveAdapter = site.adapter #site.adapter = PhpAdapter() # Create the site running with this adapter. rootPath = self.getMampRootPath(site) # Build the CSS and and PHP/HTML files in the MAMP directory. builder = CssBuilder() site.build( builder ) # Build from entire site theme, not just from template. Result is stream in builder. # Copy the PHP framework on that position all files/directories the not yet exist. # Existing files will not be overwritten, unless the forceCopy flag is True. builder.makeDirectory(rootPath) builder.copyTree(self.PHP_SIMPLEMVC, rootPath, force=forceCopy) # Save the created output onto the framework template builder.save(site, root=rootPath + 'app/templates/default/') # Create the PhpBuilder instance that can build/modify the PHP file structure. builder = PhpBuilder() # Render the website as export file, positioned over the default PHP framework.. site.build( builder ) # Build from entire site theme, not just from template. Result is stream in builder. # Copy the PHP frame work and save PHP/HTML files, builder.save(site, root=rootPath) # Restore the original adapter. site.adapter = saveAdapter # Open the site in the browser webbrowser.open('http://localhost:8888/%s/index.php' % site.getPythonClassName().lower())