def render_POST(self, request):
     """
     function replaced by nevow_clientToServerEvent to avoid POST message
     """
     log.debug("render_POST " + repr(request.args))
     data = {}
     try:
         locale = request.args['locale'][0]
         self.config.locale = locale
         self.config.locales[locale].install(unicode=True)
         self.config.configParser.set('user', 'locale', locale)
         internalAnchors = request.args['internalAnchors'][0]
         self.config.internalAnchors = internalAnchors
         self.config.configParser.set('user', 'internalAnchors', internalAnchors)
         browser = request.args['browser'][0]
         if browser == "None":
             browser = None
         try:
             self.config.browser = mywebbrowser.get(browser)
         except Exception as e:
             browser_path = Path(browser)
             if browser_path.exists():
                 mywebbrowser.register('custom-browser' , None, mywebbrowser.BackgroundBrowser(browser_path.abspath()), -1)
                 self.config.browser = mywebbrowser.get('custom-browser')
             else:
                 raise e
         self.config.configParser.set('system', 'browser', browser)
         showWizardOnStart = request.args['showWizardOnStart'][0]
         self.config.showWizardOnStart = showWizardOnStart
         self.config.configParser.set('user', 'showWizardOnStart', showWizardOnStart)
     except Exception as e:
         log.exception(e)
         return json.dumps({'success': False, 'errorMessage': _("Failed to save preferences wizard")})
     return json.dumps({'success': True, 'data': data})
Exemplo n.º 2
0
def launchBrowser(config, packageName):
    """
    Launch the configured webbrowser for this platform
    """
    url = u'%s/%s' % (G.application.exeAppUri, quote(packageName))
    log.info(u"url " + url)
    dfbrw=mywebbrowser.get()
    withdefaultbrowser=True
    if config.browser!=None:
        try:
            config.browser = mywebbrowser.get(config.browser)
            if not config.browser.open(url):
                log.error("Unable to open defined browser: " + config.browser.name)
                withdefaultbrowser = True
            else:
                withdefaultbrowser = False
        except:
            browser_path = Path(config.browser)
            if browser_path.exists():
                log.info(u"path browser " + browser_path.abspath())
                mywebbrowser.register("custom-browser" , None, mywebbrowser.BackgroundBrowser(browser_path.abspath()), -1)
                config.browser = mywebbrowser.get("custom-browser")
                if not config.browser.open(url):
                    log.error("Unable to open custom defined browser: " + browser_path.abspath())
                    withdefaultbrowser=True
                else:
                    withdefaultbrowser=False   
    if withdefaultbrowser:
        config.browser = dfbrw
        config.browser.open(url, new=0, autoraise=True)
    if hasattr(config.browser, "name"):
        log.info(u"Defined Browser: " + config.browser.name)
Exemplo n.º 3
0
    def render_POST(self, request):
        """
        function replaced by nevow_clientToServerEvent to avoid POST message
        """
        log.debug("render_POST " + repr(request.args))
        data = {}
        try:
            locale = request.args["locale"][0]
            self.config.locale = locale
            self.config.locales[locale].install(unicode=True)
            self.config.configParser.set("user", "locale", locale)

            internalAnchors = request.args["internalAnchors"][0]
            self.config.internalAnchors = internalAnchors
            self.config.configParser.set("user", "internalAnchors", internalAnchors)

            editormodesel = request.args["editorMode"][0]
            self.config.editorMode = editormodesel
            self.config.configParser.set("user", "editorMode", editormodesel)
            theme = request.args["theme"][0]
            self.config.theme = theme
            self.config.configParser.set("user", "theme", theme)

            doctypesel = request.args["docType"][0]
            self.config.docType = doctypesel
            self.config.configParser.set("user", "docType", doctypesel)

            googleApiClientID = request.args["googleApiClientID"][0]
            self.config.googleApiClientID = googleApiClientID
            self.config.configParser.set("user", "googleApiClientID", googleApiClientID)

            defaultLicense = request.args["defaultLicense"][0]
            self.config.defaultLicense = defaultLicense
            self.config.configParser.set("user", "defaultLicense", defaultLicense)

            browser = request.args["browser"][0]
            if browser == "None":
                browser = None
            try:
                self.config.browser = mywebbrowser.get(browser)
            except Exception as e:
                browser_path = Path(browser)
                if browser_path.exists():
                    mywebbrowser.register(
                        "custom-browser", None, mywebbrowser.BackgroundBrowser(browser_path.abspath()), -1
                    )
                    self.config.browser = mywebbrowser.get("custom-browser")
                else:
                    raise e
            self.config.configParser.set("system", "browser", browser)

            showPreferencesOnStart = request.args["showPreferencesOnStart"][0]
            self.config.showPreferencesOnStart = showPreferencesOnStart
            self.config.configParser.set("user", "showPreferencesOnStart", showPreferencesOnStart)
        except Exception as e:
            log.exception(e)
            return json.dumps({"success": False, "errorMessage": _("Failed to save preferences")})
        return json.dumps({"success": True, "data": data})
Exemplo n.º 4
0
    def render_POST(self, request):
        """
        function replaced by nevow_clientToServerEvent to avoid POST message
        """
        log.debug("render_POST " + repr(request.args))
        data = {}
        try:
            locale = request.args['locale'][0]
            self.config.locale = locale
            self.config.locales[locale].install(unicode=True)
            self.config.configParser.set('user', 'locale', locale)

            internalAnchors = request.args['internalAnchors'][0]
            self.config.internalAnchors = internalAnchors
            self.config.configParser.set('user', 'internalAnchors',
                                         internalAnchors)

            editormodesel = request.args['editorMode'][0]
            self.config.editorMode = editormodesel
            self.config.configParser.set('user', 'editorMode', editormodesel)

            doctypesel = request.args['docType'][0]
            self.config.docType = doctypesel
            self.config.configParser.set('user', 'docType', doctypesel)

            defaultLicense = request.args['defaultLicense'][0]
            self.config.defaultLicense = defaultLicense
            self.config.configParser.set('user', 'defaultLicense',
                                         defaultLicense)

            browser = request.args['browser'][0]
            if browser == "None":
                browser = None
            try:
                self.config.browser = mywebbrowser.get(browser)
            except Exception as e:
                browser_path = Path(browser)
                if browser_path.exists():
                    mywebbrowser.register(
                        'custom-browser', None,
                        mywebbrowser.BackgroundBrowser(browser_path.abspath()),
                        -1)
                    self.config.browser = mywebbrowser.get('custom-browser')
                else:
                    raise e
            self.config.configParser.set('system', 'browser', browser)

            showPreferencesOnStart = request.args['showPreferencesOnStart'][0]
            self.config.showPreferencesOnStart = showPreferencesOnStart
            self.config.configParser.set('user', 'showPreferencesOnStart',
                                         showPreferencesOnStart)
        except Exception as e:
            log.exception(e)
            return json.dumps({
                'success': False,
                'errorMessage': _("Failed to save preferences")
            })
        return json.dumps({'success': True, 'data': data})
Exemplo n.º 5
0
    def render_POST(self, request):
        """
        function replaced by nevow_clientToServerEvent to avoid POST message
        """
        log.debug("render_POST " + repr(request.args))
        data = {}
        try:
            locale = request.args['locale'][0]
            self.config.locale = locale
            # Change package lang too
            session = request.getSession()
            packagename = request.getPackageName()
            for name,package in session.packageStore.loaded.items():
                if name == packagename:
                    package.set_lang(locale)
            #
            self.config.locales[locale].install(unicode=True)
            self.config.configParser.set('user', 'locale', locale)

            internalAnchors = request.args['internalAnchors'][0]
            self.config.internalAnchors = internalAnchors
            self.config.configParser.set('user', 'internalAnchors', internalAnchors)

            editormodesel = request.args['editorMode'][0]
            self.config.editorMode = editormodesel
            self.config.configParser.set('user', 'editorMode', editormodesel)
            
            editorveresel = request.args['editorVersion'][0]
            self.config.editorVersion = editorveresel
            self.config.configParser.set('user', 'editorVersion', editorveresel)

            doctypesel = request.args['docType'][0]
            self.config.docType = doctypesel
            self.config.configParser.set('user', 'docType', doctypesel)

            defaultLicense = request.args['defaultLicense'][0]
            self.config.defaultLicense = defaultLicense
            self.config.configParser.set('user', 'defaultLicense', defaultLicense)
            
            forceEditableExport = request.args['forceEditableExport'][0]
            self.config.forceEditableExport = forceEditableExport
            self.config.configParser.set('user', 'forceEditableExport', forceEditableExport)
            
            cutFileName = request.args['cutFileName'][0]
            self.config.cutFileName = cutFileName
            self.config.configParser.set('user', 'cutFileName', cutFileName)
            
            autosaveTime = request.args['autosaveTime'][0]
            try: 
                float(autosaveTime)
            except Exception:
                autosaveTime = '0'
            self.config.autosaveTime = autosaveTime
            self.config.configParser.set('user', 'autosaveTime', autosaveTime)
            
            browser = request.args['browser'][0]
            if browser == "None":
                browser = None
            try:
                self.config.browser = mywebbrowser.get(browser)
            except Exception as e:
                browser_path = Path(browser)
                if browser_path.exists():
                    mywebbrowser.register('custom-browser', None, mywebbrowser.BackgroundBrowser(browser_path.abspath()), -1)
                    self.config.browser = mywebbrowser.get('custom-browser')
                else:
                    raise e
            self.config.configParser.set('system', 'browser', browser)
            
            showPreferencesOnStart = request.args['showPreferencesOnStart'][0]
            self.config.showPreferencesOnStart = showPreferencesOnStart
            self.config.configParser.set('user', 'showPreferencesOnStart', showPreferencesOnStart)
        except Exception as e:
            log.exception(e)
            return json.dumps({'success': False, 'errorMessage': _("Failed to save preferences")})
        return json.dumps({'success': True, 'data': data})
Exemplo n.º 6
0
    def render_POST(self, request):
        """
        function replaced by nevow_clientToServerEvent to avoid POST message
        """
        log.debug("render_POST " + repr(request.args))
        data = {}
        try:
            locale = request.args['locale'][0]
            self.config.locale = locale
            self.config.locales[locale].install(unicode=True)
            self.config.configParser.set('user', 'locale', locale)

            internalAnchors = request.args['internalAnchors'][0]
            self.config.internalAnchors = internalAnchors
            self.config.configParser.set('user', 'internalAnchors', internalAnchors)

            editormodesel = request.args['editorMode'][0]
            self.config.editorMode = editormodesel
            self.config.configParser.set('user', 'editorMode', editormodesel)
            
            editorveresel = request.args['editorVersion'][0]
            self.config.editorVersion = editorveresel
            self.config.configParser.set('user', 'editorVersion', editorveresel)

            doctypesel = request.args['docType'][0]
            self.config.docType = doctypesel
            self.config.configParser.set('user', 'docType', doctypesel)

            defaultLicense = request.args['defaultLicense'][0]
            self.config.defaultLicense = defaultLicense
            self.config.configParser.set('user', 'defaultLicense', defaultLicense)
            
            forceEditableExport = request.args['forceEditableExport'][0]
            self.config.forceEditableExport = forceEditableExport
            self.config.configParser.set('user', 'forceEditableExport', forceEditableExport)
            
            cutFileName = request.args['cutFileName'][0]
            self.config.cutFileName = cutFileName
            self.config.configParser.set('user', 'cutFileName', cutFileName)
            
            autosaveTime = request.args['autosaveTime'][0]
            try: 
                float(autosaveTime)
            except Exception:
                autosaveTime = '0'
            self.config.autosaveTime = autosaveTime
            self.config.configParser.set('user', 'autosaveTime', autosaveTime)
            
            browser = request.args['browser'][0]
            if browser == "None":
                browser = None
            try:
                self.config.browser = mywebbrowser.get(browser)
            except Exception as e:
                browser_path = Path(browser)
                if browser_path.exists():
                    mywebbrowser.register('custom-browser', None, mywebbrowser.BackgroundBrowser(browser_path.abspath()), -1)
                    self.config.browser = mywebbrowser.get('custom-browser')
                else:
                    raise e
            self.config.configParser.set('system', 'browser', browser)
            
            showPreferencesOnStart = request.args['showPreferencesOnStart'][0]
            self.config.showPreferencesOnStart = showPreferencesOnStart
            self.config.configParser.set('user', 'showPreferencesOnStart', showPreferencesOnStart)
        except Exception as e:
            log.exception(e)
            return json.dumps({'success': False, 'errorMessage': _("Failed to save preferences")})
        return json.dumps({'success': True, 'data': data})